
<!DOCTYPE html>

<html>
  
<!-- Mirrored from docs.sympy.org/latest/modules/polys/domainmatrix.html by HTTrack Website Copier/3.x [XR&CO'2014], Sat, 15 Jan 2022 03:29:06 GMT -->
<!-- Added by HTTrack --><meta http-equiv="content-type" content="text/html;charset=utf-8" /><!-- /Added by HTTrack -->
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" />

    <title>Introducing the domainmatrix of the poly module &#8212; SymPy 1.9 documentation</title>
    <link rel="stylesheet" type="text/css" href="../../_static/pygments.css" />
    <link rel="stylesheet" type="text/css" href="../../_static/default.css" />
    <link rel="stylesheet" type="text/css" href="../../_static/graphviz.css" />
    <link rel="stylesheet" type="text/css" href="../../_static/plot_directive.css" />
    <link rel="stylesheet" type="text/css" href="../../../../live.sympy.org/static/live-core.css" />
    <link rel="stylesheet" type="text/css" href="../../../../live.sympy.org/static/live-autocomplete.css" />
    <link rel="stylesheet" type="text/css" href="../../../../live.sympy.org/static/live-sphinx.css" />
    
    <script data-url_root="../../" id="documentation_options" src="../../_static/documentation_options.js"></script>
    <script src="../../_static/jquery.js"></script>
    <script src="../../_static/underscore.js"></script>
    <script src="../../_static/doctools.js"></script>
    <script src="../../../../live.sympy.org/static/utilities.js"></script>
    <script src="../../../../live.sympy.org/static/external/classy.js"></script>
    <script src="../../../../live.sympy.org/static/live-core.js"></script>
    <script src="../../../../live.sympy.org/static/live-autocomplete.js"></script>
    <script src="../../../../live.sympy.org/static/live-sphinx.js"></script>
    <script async="async" src="../../../../cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/latest8331.js?config=TeX-AMS_HTML-full"></script>
    <script type="text/x-mathjax-config">MathJax.Hub.Config({"tex2jax": {"inlineMath": [["\\(", "\\)"]], "displayMath": [["\\[", "\\]"]]}})</script>
    
    <link rel="shortcut icon" href="../../_static/sympy-notailtext-favicon.ico"/>
    <link href="domainmatrix.html" rel="canonical" />
    
    <link rel="index" title="Index" href="../../genindex.html" />
    <link rel="search" title="Search" href="../../search.html" />
    <link rel="next" title="Printing" href="../printing.html" />
    <link rel="prev" title="Poly solvers" href="solvers.html" /> 
  </head><body>
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../../genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="../../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="../printing.html" title="Printing"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="solvers.html" title="Poly solvers"
             accesskey="P">previous</a> |</li>
        <li class="nav-item nav-item-0"><a href="../../index.html">SymPy 1.9 documentation</a> &#187;</li>
          <li class="nav-item nav-item-1"><a href="../index.html" >SymPy Modules Reference</a> &#187;</li>
          <li class="nav-item nav-item-2"><a href="index.html" accesskey="U">Polynomial Manipulation</a> &#187;</li>
        <li class="nav-item nav-item-this"><a href="#">Introducing the domainmatrix of the poly module</a></li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body" role="main">
            
  <section id="introducing-the-domainmatrix-of-the-poly-module">
<span id="polys-domainmatrix"></span><h1>Introducing the domainmatrix of the poly module<a class="headerlink" href="#introducing-the-domainmatrix-of-the-poly-module" title="Permalink to this headline">¶</a></h1>
<p>This page introduces the idea behind domainmatrix which is used in SymPy’s
<a class="reference internal" href="reference.html#module-sympy.polys" title="sympy.polys"><code class="xref py py-mod docutils literal notranslate"><span class="pre">sympy.polys</span></code></a> module. This is a relatively advanced topic so for a better understanding
it is recommended to read about <a class="reference internal" href="domainsref.html#sympy.polys.domains.domain.Domain" title="sympy.polys.domains.domain.Domain"><code class="xref py py-class docutils literal notranslate"><span class="pre">Domain</span></code></a> and <a class="reference internal" href="#sympy.polys.matrices.ddm.DDM" title="sympy.polys.matrices.ddm.DDM"><code class="xref py py-class docutils literal notranslate"><span class="pre">DDM</span></code></a> along with
<a class="reference internal" href="../matrices/index.html#module-sympy.matrices" title="sympy.matrices"><code class="xref py py-mod docutils literal notranslate"><span class="pre">sympy.matrices</span></code></a> module.</p>
<section id="what-is-domainmatrix">
<h2>What is domainmatrix?<a class="headerlink" href="#what-is-domainmatrix" title="Permalink to this headline">¶</a></h2>
<p>It is way of associating Matrix with <a class="reference internal" href="domainsref.html#sympy.polys.domains.domain.Domain" title="sympy.polys.domains.domain.Domain"><code class="xref py py-class docutils literal notranslate"><span class="pre">Domain</span></code></a>.</p>
<p>A domainmatrix represents a matrix with elements that are in a particular
Domain. Each domainmatrix internally wraps a DDM which is used for the lower-level operations.
The idea is that the domainmatrix class provides the convenience routines for converting
between Expr and the poly domains as well as unifying matrices with different domains.</p>
<dl>
<dt>In general, we represent a matrix without concerning about the <a class="reference internal" href="domainsref.html#sympy.polys.domains.domain.Domain" title="sympy.polys.domains.domain.Domain"><code class="xref py py-class docutils literal notranslate"><span class="pre">Domain</span></code></a> as:</dt><dd><div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Matrix</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.matrices</span> <span class="kn">import</span> <span class="n">DomainMatrix</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">A</span> <span class="o">=</span> <span class="n">Matrix</span><span class="p">([</span>
<span class="gp">... </span><span class="p">[</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">],</span>
<span class="gp">... </span><span class="p">[</span><span class="mi">3</span><span class="p">,</span> <span class="mi">4</span><span class="p">]])</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">A</span>
<span class="go">Matrix([</span>
<span class="go">[1, 2],</span>
<span class="go">[3, 4]])</span>
</pre></div>
</div>
</dd>
</dl>
</section>
<section id="domainmatrix-class-reference">
<h2>DomainMatrix Class Reference<a class="headerlink" href="#domainmatrix-class-reference" title="Permalink to this headline">¶</a></h2>
<dl class="py class">
<dt class="sig sig-object py" id="sympy.polys.matrices.domainmatrix.DomainMatrix">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">sympy.polys.matrices.domainmatrix.</span></span><span class="sig-name descname"><span class="pre">DomainMatrix</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">rows</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">shape</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">domain</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">*</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">fmt</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/matrices/domainmatrix.py#L28-L1534"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.matrices.domainmatrix.DomainMatrix" title="Permalink to this definition">¶</a></dt>
<dd><p>Associate Matrix with <a class="reference internal" href="domainsref.html#sympy.polys.domains.domain.Domain" title="sympy.polys.domains.domain.Domain"><code class="xref py py-class docutils literal notranslate"><span class="pre">Domain</span></code></a></p>
<p class="rubric">Explanation</p>
<p>DomainMatrix uses <a class="reference internal" href="domainsref.html#sympy.polys.domains.domain.Domain" title="sympy.polys.domains.domain.Domain"><code class="xref py py-class docutils literal notranslate"><span class="pre">Domain</span></code></a> for its internal representation
which makes it more faster for many common operations
than current sympy Matrix class, but this advantage makes it not
entirely compatible with Matrix.
DomainMatrix could be found analogous to numpy arrays with “dtype”.
In the DomainMatrix, each matrix has a domain such as <a class="reference internal" href="domainsref.html#zz"><span class="std std-ref">ZZ</span></a>
or  <a class="reference internal" href="domainsref.html#qq-a"><span class="std std-ref">QQ&lt;a&gt;</span></a>.</p>
<p class="rubric">Examples</p>
<p>Creating a DomainMatrix from the existing Matrix class:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Matrix</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.matrices</span> <span class="kn">import</span> <span class="n">DomainMatrix</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">Matrix1</span> <span class="o">=</span> <span class="n">Matrix</span><span class="p">([</span>
<span class="gp">... </span>   <span class="p">[</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">],</span>
<span class="gp">... </span>   <span class="p">[</span><span class="mi">3</span><span class="p">,</span> <span class="mi">4</span><span class="p">]])</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">A</span> <span class="o">=</span> <span class="n">DomainMatrix</span><span class="o">.</span><span class="n">from_Matrix</span><span class="p">(</span><span class="n">Matrix1</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">A</span>
<span class="go">DomainMatrix({0: {0: 1, 1: 2}, 1: {0: 3, 1: 4}}, (2, 2), ZZ)</span>
</pre></div>
</div>
<p>Driectly forming a DomainMatrix:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.matrices</span> <span class="kn">import</span> <span class="n">DomainMatrix</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">A</span> <span class="o">=</span> <span class="n">DomainMatrix</span><span class="p">([</span>
<span class="gp">... </span>   <span class="p">[</span><span class="n">ZZ</span><span class="p">(</span><span class="mi">1</span><span class="p">),</span> <span class="n">ZZ</span><span class="p">(</span><span class="mi">2</span><span class="p">)],</span>
<span class="gp">... </span>   <span class="p">[</span><span class="n">ZZ</span><span class="p">(</span><span class="mi">3</span><span class="p">),</span> <span class="n">ZZ</span><span class="p">(</span><span class="mi">4</span><span class="p">)]],</span> <span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">2</span><span class="p">),</span> <span class="n">ZZ</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">A</span>
<span class="go">DomainMatrix([[1, 2], [3, 4]], (2, 2), ZZ)</span>
</pre></div>
</div>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<p><a class="reference internal" href="#sympy.polys.matrices.ddm.DDM" title="sympy.polys.matrices.ddm.DDM"><code class="xref py py-obj docutils literal notranslate"><span class="pre">DDM</span></code></a>, <a class="reference internal" href="#sympy.polys.matrices.sdm.SDM" title="sympy.polys.matrices.sdm.SDM"><code class="xref py py-obj docutils literal notranslate"><span class="pre">SDM</span></code></a>, <a class="reference internal" href="domainsref.html#sympy.polys.domains.domain.Domain" title="sympy.polys.domains.domain.Domain"><code class="xref py py-obj docutils literal notranslate"><span class="pre">Domain</span></code></a>, <a class="reference internal" href="reference.html#sympy.polys.polytools.Poly" title="sympy.polys.polytools.Poly"><code class="xref py py-obj docutils literal notranslate"><span class="pre">Poly</span></code></a></p>
</div>
<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.matrices.domainmatrix.DomainMatrix.add">
<span class="sig-name descname"><span class="pre">add</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">B</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/matrices/domainmatrix.py#L746-L793"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.matrices.domainmatrix.DomainMatrix.add" title="Permalink to this definition">¶</a></dt>
<dd><p>Adds two DomainMatrix matrices of the same Domain</p>
<dl class="field-list">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>A, B: DomainMatrix</strong></p>
<blockquote>
<div><p>matrices to add</p>
</div></blockquote>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>DomainMatrix</p>
<blockquote>
<div><p>DomainMatrix after Addition</p>
</div></blockquote>
</dd>
<dt class="field-odd">Raises</dt>
<dd class="field-odd"><p><strong>ShapeError</strong></p>
<blockquote>
<div><p>If the dimensions of the two DomainMatrix are not equal</p>
</div></blockquote>
<p><strong>ValueError</strong></p>
<blockquote>
<div><p>If the domain of the two DomainMatrix are not same</p>
</div></blockquote>
</dd>
</dl>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.matrices</span> <span class="kn">import</span> <span class="n">DomainMatrix</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">A</span> <span class="o">=</span> <span class="n">DomainMatrix</span><span class="p">([</span>
<span class="gp">... </span>   <span class="p">[</span><span class="n">ZZ</span><span class="p">(</span><span class="mi">1</span><span class="p">),</span> <span class="n">ZZ</span><span class="p">(</span><span class="mi">2</span><span class="p">)],</span>
<span class="gp">... </span>   <span class="p">[</span><span class="n">ZZ</span><span class="p">(</span><span class="mi">3</span><span class="p">),</span> <span class="n">ZZ</span><span class="p">(</span><span class="mi">4</span><span class="p">)]],</span> <span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">2</span><span class="p">),</span> <span class="n">ZZ</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">B</span> <span class="o">=</span> <span class="n">DomainMatrix</span><span class="p">([</span>
<span class="gp">... </span>   <span class="p">[</span><span class="n">ZZ</span><span class="p">(</span><span class="mi">4</span><span class="p">),</span> <span class="n">ZZ</span><span class="p">(</span><span class="mi">3</span><span class="p">)],</span>
<span class="gp">... </span>   <span class="p">[</span><span class="n">ZZ</span><span class="p">(</span><span class="mi">2</span><span class="p">),</span> <span class="n">ZZ</span><span class="p">(</span><span class="mi">1</span><span class="p">)]],</span> <span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">2</span><span class="p">),</span> <span class="n">ZZ</span><span class="p">)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">A</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="n">B</span><span class="p">)</span>
<span class="go">DomainMatrix([[5, 5], [5, 5]], (2, 2), ZZ)</span>
</pre></div>
</div>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<p><a class="reference internal" href="#sympy.polys.matrices.domainmatrix.DomainMatrix.sub" title="sympy.polys.matrices.domainmatrix.DomainMatrix.sub"><code class="xref py py-obj docutils literal notranslate"><span class="pre">sub</span></code></a>, <a class="reference internal" href="#sympy.polys.matrices.domainmatrix.DomainMatrix.matmul" title="sympy.polys.matrices.domainmatrix.DomainMatrix.matmul"><code class="xref py py-obj docutils literal notranslate"><span class="pre">matmul</span></code></a></p>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.matrices.domainmatrix.DomainMatrix.charpoly">
<span class="sig-name descname"><span class="pre">charpoly</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/matrices/domainmatrix.py#L1383-L1417"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.matrices.domainmatrix.DomainMatrix.charpoly" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns the coefficients of the characteristic polynomial
of the DomainMatrix. These elements will be domain elements.
The domain of the elements will be same as domain of the DomainMatrix.</p>
<dl class="field-list">
<dt class="field-odd">Returns</dt>
<dd class="field-odd"><p>list</p>
<blockquote>
<div><p>coefficients of the characteristic polynomial</p>
</div></blockquote>
</dd>
<dt class="field-even">Raises</dt>
<dd class="field-even"><p><strong>NonSquareMatrixError</strong></p>
<blockquote>
<div><p>If the DomainMatrix is not a not Square DomainMatrix</p>
</div></blockquote>
</dd>
</dl>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.matrices</span> <span class="kn">import</span> <span class="n">DomainMatrix</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">A</span> <span class="o">=</span> <span class="n">DomainMatrix</span><span class="p">([</span>
<span class="gp">... </span>   <span class="p">[</span><span class="n">ZZ</span><span class="p">(</span><span class="mi">1</span><span class="p">),</span> <span class="n">ZZ</span><span class="p">(</span><span class="mi">2</span><span class="p">)],</span>
<span class="gp">... </span>   <span class="p">[</span><span class="n">ZZ</span><span class="p">(</span><span class="mi">3</span><span class="p">),</span> <span class="n">ZZ</span><span class="p">(</span><span class="mi">4</span><span class="p">)]],</span> <span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">2</span><span class="p">),</span> <span class="n">ZZ</span><span class="p">)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">A</span><span class="o">.</span><span class="n">charpoly</span><span class="p">()</span>
<span class="go">[1, -5, -2]</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.matrices.domainmatrix.DomainMatrix.convert_to">
<span class="sig-name descname"><span class="pre">convert_to</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/matrices/domainmatrix.py#L364-L392"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.matrices.domainmatrix.DomainMatrix.convert_to" title="Permalink to this definition">¶</a></dt>
<dd><p>Change the domain of DomainMatrix to desired domain or field</p>
<dl class="field-list">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>K</strong> : Represents the desired domain or field</p>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>DomainMatrix</p>
<blockquote>
<div><p>DomainMatrix with the desired domain or field</p>
</div></blockquote>
</dd>
</dl>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">ZZ</span><span class="p">,</span> <span class="n">ZZ_I</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.matrices</span> <span class="kn">import</span> <span class="n">DomainMatrix</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">A</span> <span class="o">=</span> <span class="n">DomainMatrix</span><span class="p">([</span>
<span class="gp">... </span>   <span class="p">[</span><span class="n">ZZ</span><span class="p">(</span><span class="mi">1</span><span class="p">),</span> <span class="n">ZZ</span><span class="p">(</span><span class="mi">2</span><span class="p">)],</span>
<span class="gp">... </span>   <span class="p">[</span><span class="n">ZZ</span><span class="p">(</span><span class="mi">3</span><span class="p">),</span> <span class="n">ZZ</span><span class="p">(</span><span class="mi">4</span><span class="p">)]],</span> <span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">2</span><span class="p">),</span> <span class="n">ZZ</span><span class="p">)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">A</span><span class="o">.</span><span class="n">convert_to</span><span class="p">(</span><span class="n">ZZ_I</span><span class="p">)</span>
<span class="go">DomainMatrix([[1, 2], [3, 4]], (2, 2), ZZ_I)</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.matrices.domainmatrix.DomainMatrix.det">
<span class="sig-name descname"><span class="pre">det</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/matrices/domainmatrix.py#L1244-L1276"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.matrices.domainmatrix.DomainMatrix.det" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns the determinant of a Square DomainMatrix</p>
<dl class="field-list">
<dt class="field-odd">Returns</dt>
<dd class="field-odd"><p>S.Complexes</p>
<blockquote>
<div><p>determinant of Square DomainMatrix</p>
</div></blockquote>
</dd>
<dt class="field-even">Raises</dt>
<dd class="field-even"><p><strong>ValueError</strong></p>
<blockquote>
<div><p>If the domain of DomainMatrix not a Field</p>
</div></blockquote>
</dd>
</dl>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.matrices</span> <span class="kn">import</span> <span class="n">DomainMatrix</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">A</span> <span class="o">=</span> <span class="n">DomainMatrix</span><span class="p">([</span>
<span class="gp">... </span>   <span class="p">[</span><span class="n">ZZ</span><span class="p">(</span><span class="mi">1</span><span class="p">),</span> <span class="n">ZZ</span><span class="p">(</span><span class="mi">2</span><span class="p">)],</span>
<span class="gp">... </span>   <span class="p">[</span><span class="n">ZZ</span><span class="p">(</span><span class="mi">3</span><span class="p">),</span> <span class="n">ZZ</span><span class="p">(</span><span class="mi">4</span><span class="p">)]],</span> <span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">2</span><span class="p">),</span> <span class="n">ZZ</span><span class="p">)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">A</span><span class="o">.</span><span class="n">det</span><span class="p">()</span>
<span class="go">-2</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.matrices.domainmatrix.DomainMatrix.diag">
<em class="property"><span class="pre">classmethod</span> </em><span class="sig-name descname"><span class="pre">diag</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">diagonal</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">domain</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">shape</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/matrices/domainmatrix.py#L1437-L1454"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.matrices.domainmatrix.DomainMatrix.diag" title="Permalink to this definition">¶</a></dt>
<dd><p>Return diagonal matrix with entries from <code class="docutils literal notranslate"><span class="pre">diagonal</span></code>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.matrices</span> <span class="kn">import</span> <span class="n">DomainMatrix</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">DomainMatrix</span><span class="o">.</span><span class="n">diag</span><span class="p">([</span><span class="n">ZZ</span><span class="p">(</span><span class="mi">5</span><span class="p">),</span> <span class="n">ZZ</span><span class="p">(</span><span class="mi">6</span><span class="p">)],</span> <span class="n">ZZ</span><span class="p">)</span>
<span class="go">DomainMatrix({0: {0: 5}, 1: {1: 6}}, (2, 2), ZZ)</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.matrices.domainmatrix.DomainMatrix.eye">
<em class="property"><span class="pre">classmethod</span> </em><span class="sig-name descname"><span class="pre">eye</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">shape</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">domain</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/matrices/domainmatrix.py#L1419-L1435"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.matrices.domainmatrix.DomainMatrix.eye" title="Permalink to this definition">¶</a></dt>
<dd><p>Return identity matrix of size n</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.matrices</span> <span class="kn">import</span> <span class="n">DomainMatrix</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">QQ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">DomainMatrix</span><span class="o">.</span><span class="n">eye</span><span class="p">(</span><span class="mi">3</span><span class="p">,</span> <span class="n">QQ</span><span class="p">)</span>
<span class="go">DomainMatrix({0: {0: 1}, 1: {1: 1}, 2: {2: 1}}, (3, 3), QQ)</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.matrices.domainmatrix.DomainMatrix.from_Matrix">
<em class="property"><span class="pre">classmethod</span> </em><span class="sig-name descname"><span class="pre">from_Matrix</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">M</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">fmt</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'sparse'</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kwargs</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/matrices/domainmatrix.py#L311-L354"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.matrices.domainmatrix.DomainMatrix.from_Matrix" title="Permalink to this definition">¶</a></dt>
<dd><p>Convert Matrix to DomainMatrix</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>M: Matrix</strong></p>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>Returns DomainMatrix with identical elements as M</p>
</dd>
</dl>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">Matrix</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.matrices</span> <span class="kn">import</span> <span class="n">DomainMatrix</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">M</span> <span class="o">=</span> <span class="n">Matrix</span><span class="p">([</span>
<span class="gp">... </span>   <span class="p">[</span><span class="mf">1.0</span><span class="p">,</span> <span class="mf">3.4</span><span class="p">],</span>
<span class="gp">... </span>   <span class="p">[</span><span class="mf">2.4</span><span class="p">,</span> <span class="mi">1</span><span class="p">]])</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">A</span> <span class="o">=</span> <span class="n">DomainMatrix</span><span class="o">.</span><span class="n">from_Matrix</span><span class="p">(</span><span class="n">M</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">A</span>
<span class="go">DomainMatrix({0: {0: 1.0, 1: 3.4}, 1: {0: 2.4, 1: 1.0}}, (2, 2), RR)</span>
</pre></div>
</div>
<p>We can keep internal representation as ddm using fmt=’dense’
&gt;&gt;&gt; from sympy import Matrix, QQ
&gt;&gt;&gt; from sympy.polys.matrices import DomainMatrix
&gt;&gt;&gt; A = DomainMatrix.from_Matrix(Matrix([[QQ(1, 2), QQ(3, 4)], [QQ(0, 1), QQ(0, 1)]]), fmt=’dense’)
&gt;&gt;&gt; A.rep
[[1/2, 3/4], [0, 0]]</p>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<p><a class="reference internal" href="../matrices/dense.html#sympy.matrices.dense.Matrix" title="sympy.matrices.dense.Matrix"><code class="xref py py-obj docutils literal notranslate"><span class="pre">Matrix</span></code></a></p>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.matrices.domainmatrix.DomainMatrix.from_dict_sympy">
<em class="property"><span class="pre">classmethod</span> </em><span class="sig-name descname"><span class="pre">from_dict_sympy</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">nrows</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">ncols</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">elemsdict</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kwargs</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/matrices/domainmatrix.py#L261-L309"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.matrices.domainmatrix.DomainMatrix.from_dict_sympy" title="Permalink to this definition">¶</a></dt>
<dd><dl class="field-list">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>nrows: number of rows</strong></p>
<p><strong>ncols: number of cols</strong></p>
<p><strong>elemsdict: dict of dicts containing non-zero elements of the DomainMatrix</strong></p>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>DomainMatrix containing elements of elemsdict</p>
</dd>
</dl>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.matrices</span> <span class="kn">import</span> <span class="n">DomainMatrix</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span><span class="p">,</span><span class="n">y</span><span class="p">,</span><span class="n">z</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">elemsdict</span> <span class="o">=</span> <span class="p">{</span><span class="mi">0</span><span class="p">:</span> <span class="p">{</span><span class="mi">0</span><span class="p">:</span><span class="n">x</span><span class="p">},</span> <span class="mi">1</span><span class="p">:{</span><span class="mi">1</span><span class="p">:</span> <span class="n">y</span><span class="p">},</span> <span class="mi">2</span><span class="p">:</span> <span class="p">{</span><span class="mi">2</span><span class="p">:</span> <span class="n">z</span><span class="p">}}</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">A</span> <span class="o">=</span> <span class="n">DomainMatrix</span><span class="o">.</span><span class="n">from_dict_sympy</span><span class="p">(</span><span class="mi">3</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="n">elemsdict</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">A</span>
<span class="go">DomainMatrix({0: {0: x}, 1: {1: y}, 2: {2: z}}, (3, 3), ZZ[x,y,z])</span>
</pre></div>
</div>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<p><a class="reference internal" href="#sympy.polys.matrices.domainmatrix.DomainMatrix.from_list_sympy" title="sympy.polys.matrices.domainmatrix.DomainMatrix.from_list_sympy"><code class="xref py py-obj docutils literal notranslate"><span class="pre">from_list_sympy</span></code></a></p>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.matrices.domainmatrix.DomainMatrix.from_list_sympy">
<em class="property"><span class="pre">classmethod</span> </em><span class="sig-name descname"><span class="pre">from_list_sympy</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">nrows</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">ncols</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">rows</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kwargs</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/matrices/domainmatrix.py#L218-L259"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.matrices.domainmatrix.DomainMatrix.from_list_sympy" title="Permalink to this definition">¶</a></dt>
<dd><p>Convert a list of lists of Expr into a DomainMatrix using construct_domain</p>
<dl class="field-list">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>nrows: number of rows</strong></p>
<p><strong>ncols: number of columns</strong></p>
<p><strong>rows: list of lists</strong></p>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>DomainMatrix containing elements of rows</p>
</dd>
</dl>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.matrices</span> <span class="kn">import</span> <span class="n">DomainMatrix</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.abc</span> <span class="kn">import</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">,</span> <span class="n">z</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">A</span> <span class="o">=</span> <span class="n">DomainMatrix</span><span class="o">.</span><span class="n">from_list_sympy</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="p">[[</span><span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">,</span> <span class="n">z</span><span class="p">]])</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">A</span>
<span class="go">DomainMatrix([[x, y, z]], (1, 3), ZZ[x,y,z])</span>
</pre></div>
</div>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<p><a class="reference internal" href="reference.html#sympy.polys.constructor.construct_domain" title="sympy.polys.constructor.construct_domain"><code class="xref py py-obj docutils literal notranslate"><span class="pre">sympy.polys.constructor.construct_domain</span></code></a>, <a class="reference internal" href="#sympy.polys.matrices.domainmatrix.DomainMatrix.from_dict_sympy" title="sympy.polys.matrices.domainmatrix.DomainMatrix.from_dict_sympy"><code class="xref py py-obj docutils literal notranslate"><span class="pre">from_dict_sympy</span></code></a></p>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.matrices.domainmatrix.DomainMatrix.from_rep">
<em class="property"><span class="pre">classmethod</span> </em><span class="sig-name descname"><span class="pre">from_rep</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">rep</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/matrices/domainmatrix.py#L160-L216"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.matrices.domainmatrix.DomainMatrix.from_rep" title="Permalink to this definition">¶</a></dt>
<dd><p>Create a new DomainMatrix efficiently from DDM/SDM.</p>
<dl class="field-list">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>rep: SDM or DDM</strong></p>
<blockquote>
<div><p>The internal sparse or dense representation of the matrix.</p>
</div></blockquote>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>DomainMatrix</p>
<blockquote>
<div><p>A <a class="reference internal" href="#sympy.polys.matrices.domainmatrix.DomainMatrix" title="sympy.polys.matrices.domainmatrix.DomainMatrix"><code class="xref py py-class docutils literal notranslate"><span class="pre">DomainMatrix</span></code></a> wrapping <em>rep</em>.</p>
</div></blockquote>
</dd>
</dl>
<p class="rubric">Examples</p>
<p>Create a <a class="reference internal" href="#sympy.polys.matrices.domainmatrix.DomainMatrix" title="sympy.polys.matrices.domainmatrix.DomainMatrix"><code class="xref py py-class docutils literal notranslate"><span class="pre">DomainMatrix</span></code></a> with an dense internal
representation as <a class="reference internal" href="#sympy.polys.matrices.ddm.DDM" title="sympy.polys.matrices.ddm.DDM"><code class="xref py py-class docutils literal notranslate"><span class="pre">DDM</span></code></a>:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.domains</span> <span class="kn">import</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.matrices</span> <span class="kn">import</span> <span class="n">DomainMatrix</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.matrices.ddm</span> <span class="kn">import</span> <span class="n">DDM</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">drep</span> <span class="o">=</span> <span class="n">DDM</span><span class="p">([[</span><span class="n">ZZ</span><span class="p">(</span><span class="mi">1</span><span class="p">),</span> <span class="n">ZZ</span><span class="p">(</span><span class="mi">2</span><span class="p">)],</span> <span class="p">[</span><span class="n">ZZ</span><span class="p">(</span><span class="mi">3</span><span class="p">),</span> <span class="n">ZZ</span><span class="p">(</span><span class="mi">4</span><span class="p">)]],</span> <span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">2</span><span class="p">),</span> <span class="n">ZZ</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">dM</span> <span class="o">=</span> <span class="n">DomainMatrix</span><span class="o">.</span><span class="n">from_rep</span><span class="p">(</span><span class="n">drep</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">dM</span>
<span class="go">DomainMatrix([[1, 2], [3, 4]], (2, 2), ZZ)</span>
</pre></div>
</div>
<p>Create a <a class="reference internal" href="#sympy.polys.matrices.domainmatrix.DomainMatrix" title="sympy.polys.matrices.domainmatrix.DomainMatrix"><code class="xref py py-class docutils literal notranslate"><span class="pre">DomainMatrix</span></code></a> with a sparse internal
representation as <a class="reference internal" href="#sympy.polys.matrices.sdm.SDM" title="sympy.polys.matrices.sdm.SDM"><code class="xref py py-class docutils literal notranslate"><span class="pre">SDM</span></code></a>:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.matrices</span> <span class="kn">import</span> <span class="n">DomainMatrix</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.matrices.sdm</span> <span class="kn">import</span> <span class="n">SDM</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">drep</span> <span class="o">=</span> <span class="n">SDM</span><span class="p">({</span><span class="mi">0</span><span class="p">:{</span><span class="mi">1</span><span class="p">:</span><span class="n">ZZ</span><span class="p">(</span><span class="mi">1</span><span class="p">)},</span><span class="mi">1</span><span class="p">:{</span><span class="mi">0</span><span class="p">:</span><span class="n">ZZ</span><span class="p">(</span><span class="mi">2</span><span class="p">)}},</span> <span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">2</span><span class="p">),</span> <span class="n">ZZ</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">dM</span> <span class="o">=</span> <span class="n">DomainMatrix</span><span class="o">.</span><span class="n">from_rep</span><span class="p">(</span><span class="n">drep</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">dM</span>
<span class="go">DomainMatrix({0: {1: 1}, 1: {0: 2}}, (2, 2), ZZ)</span>
</pre></div>
</div>
<p class="rubric">Notes</p>
<p>This takes ownership of rep as its internal representation. If rep is
being mutated elsewhere then a copy should be provided to
<code class="docutils literal notranslate"><span class="pre">from_rep</span></code>. Only minimal verification or checking is done on <em>rep</em>
as this is supposed to be an efficient internal routine.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.matrices.domainmatrix.DomainMatrix.hstack">
<span class="sig-name descname"><span class="pre">hstack</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">B</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/matrices/domainmatrix.py#L611-L647"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.matrices.domainmatrix.DomainMatrix.hstack" title="Permalink to this definition">¶</a></dt>
<dd><p>Horizontally stack the given matrices.</p>
<dl class="field-list">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>B: DomainMatrix</strong></p>
<blockquote>
<div><p>Matrices to stack horizontally.</p>
</div></blockquote>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>DomainMatrix</p>
<blockquote>
<div><p>DomainMatrix by stacking horizontally.</p>
</div></blockquote>
</dd>
</dl>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.matrices</span> <span class="kn">import</span> <span class="n">DomainMatrix</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">A</span> <span class="o">=</span> <span class="n">DomainMatrix</span><span class="p">([[</span><span class="n">ZZ</span><span class="p">(</span><span class="mi">1</span><span class="p">),</span> <span class="n">ZZ</span><span class="p">(</span><span class="mi">2</span><span class="p">)],</span> <span class="p">[</span><span class="n">ZZ</span><span class="p">(</span><span class="mi">3</span><span class="p">),</span> <span class="n">ZZ</span><span class="p">(</span><span class="mi">4</span><span class="p">)]],</span> <span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">2</span><span class="p">),</span> <span class="n">ZZ</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">B</span> <span class="o">=</span> <span class="n">DomainMatrix</span><span class="p">([[</span><span class="n">ZZ</span><span class="p">(</span><span class="mi">5</span><span class="p">),</span> <span class="n">ZZ</span><span class="p">(</span><span class="mi">6</span><span class="p">)],</span> <span class="p">[</span><span class="n">ZZ</span><span class="p">(</span><span class="mi">7</span><span class="p">),</span> <span class="n">ZZ</span><span class="p">(</span><span class="mi">8</span><span class="p">)]],</span> <span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">2</span><span class="p">),</span> <span class="n">ZZ</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">A</span><span class="o">.</span><span class="n">hstack</span><span class="p">(</span><span class="n">B</span><span class="p">)</span>
<span class="go">DomainMatrix([[1, 2, 5, 6], [3, 4, 7, 8]], (2, 4), ZZ)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">C</span> <span class="o">=</span> <span class="n">DomainMatrix</span><span class="p">([[</span><span class="n">ZZ</span><span class="p">(</span><span class="mi">9</span><span class="p">),</span> <span class="n">ZZ</span><span class="p">(</span><span class="mi">10</span><span class="p">)],</span> <span class="p">[</span><span class="n">ZZ</span><span class="p">(</span><span class="mi">11</span><span class="p">),</span> <span class="n">ZZ</span><span class="p">(</span><span class="mi">12</span><span class="p">)]],</span> <span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">2</span><span class="p">),</span> <span class="n">ZZ</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">A</span><span class="o">.</span><span class="n">hstack</span><span class="p">(</span><span class="n">B</span><span class="p">,</span> <span class="n">C</span><span class="p">)</span>
<span class="go">DomainMatrix([[1, 2, 5, 6, 9, 10], [3, 4, 7, 8, 11, 12]], (2, 6), ZZ)</span>
</pre></div>
</div>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<p><a class="reference internal" href="#sympy.polys.matrices.domainmatrix.DomainMatrix.unify" title="sympy.polys.matrices.domainmatrix.DomainMatrix.unify"><code class="xref py py-obj docutils literal notranslate"><span class="pre">unify</span></code></a></p>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.matrices.domainmatrix.DomainMatrix.inv">
<span class="sig-name descname"><span class="pre">inv</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/matrices/domainmatrix.py#L1199-L1242"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.matrices.domainmatrix.DomainMatrix.inv" title="Permalink to this definition">¶</a></dt>
<dd><p>Finds the inverse of the DomainMatrix if exists</p>
<dl class="field-list">
<dt class="field-odd">Returns</dt>
<dd class="field-odd"><p>DomainMatrix</p>
<blockquote>
<div><p>DomainMatrix after inverse</p>
</div></blockquote>
</dd>
<dt class="field-even">Raises</dt>
<dd class="field-even"><p><strong>ValueError</strong></p>
<blockquote>
<div><p>If the domain of DomainMatrix not a Field</p>
</div></blockquote>
<p><strong>NonSquareMatrixError</strong></p>
<blockquote>
<div><p>If the DomainMatrix is not a not Square DomainMatrix</p>
</div></blockquote>
</dd>
</dl>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">QQ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.matrices</span> <span class="kn">import</span> <span class="n">DomainMatrix</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">A</span> <span class="o">=</span> <span class="n">DomainMatrix</span><span class="p">([</span>
<span class="gp">... </span>    <span class="p">[</span><span class="n">QQ</span><span class="p">(</span><span class="mi">2</span><span class="p">),</span> <span class="n">QQ</span><span class="p">(</span><span class="o">-</span><span class="mi">1</span><span class="p">),</span> <span class="n">QQ</span><span class="p">(</span><span class="mi">0</span><span class="p">)],</span>
<span class="gp">... </span>    <span class="p">[</span><span class="n">QQ</span><span class="p">(</span><span class="o">-</span><span class="mi">1</span><span class="p">),</span> <span class="n">QQ</span><span class="p">(</span><span class="mi">2</span><span class="p">),</span> <span class="n">QQ</span><span class="p">(</span><span class="o">-</span><span class="mi">1</span><span class="p">)],</span>
<span class="gp">... </span>    <span class="p">[</span><span class="n">QQ</span><span class="p">(</span><span class="mi">0</span><span class="p">),</span> <span class="n">QQ</span><span class="p">(</span><span class="mi">0</span><span class="p">),</span> <span class="n">QQ</span><span class="p">(</span><span class="mi">2</span><span class="p">)]],</span> <span class="p">(</span><span class="mi">3</span><span class="p">,</span> <span class="mi">3</span><span class="p">),</span> <span class="n">QQ</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">A</span><span class="o">.</span><span class="n">inv</span><span class="p">()</span>
<span class="go">DomainMatrix([[2/3, 1/3, 1/6], [1/3, 2/3, 1/3], [0, 0, 1/2]], (3, 3), QQ)</span>
</pre></div>
</div>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<p><a class="reference internal" href="#sympy.polys.matrices.domainmatrix.DomainMatrix.neg" title="sympy.polys.matrices.domainmatrix.DomainMatrix.neg"><code class="xref py py-obj docutils literal notranslate"><span class="pre">neg</span></code></a></p>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.matrices.domainmatrix.DomainMatrix.lu">
<span class="sig-name descname"><span class="pre">lu</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/matrices/domainmatrix.py#L1278-L1315"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.matrices.domainmatrix.DomainMatrix.lu" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns Lower and Upper decomposition of the DomainMatrix</p>
<dl class="field-list">
<dt class="field-odd">Returns</dt>
<dd class="field-odd"><p>(L, U, exchange)</p>
<blockquote>
<div><p>L, U are Lower and Upper decomposition of the DomainMatrix,
exchange is the list of indices of rows exchanged in the decomposition.</p>
</div></blockquote>
</dd>
<dt class="field-even">Raises</dt>
<dd class="field-even"><p><strong>ValueError</strong></p>
<blockquote>
<div><p>If the domain of DomainMatrix not a Field</p>
</div></blockquote>
</dd>
</dl>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">QQ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.matrices</span> <span class="kn">import</span> <span class="n">DomainMatrix</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">A</span> <span class="o">=</span> <span class="n">DomainMatrix</span><span class="p">([</span>
<span class="gp">... </span>   <span class="p">[</span><span class="n">QQ</span><span class="p">(</span><span class="mi">1</span><span class="p">),</span> <span class="n">QQ</span><span class="p">(</span><span class="o">-</span><span class="mi">1</span><span class="p">)],</span>
<span class="gp">... </span>   <span class="p">[</span><span class="n">QQ</span><span class="p">(</span><span class="mi">2</span><span class="p">),</span> <span class="n">QQ</span><span class="p">(</span><span class="o">-</span><span class="mi">2</span><span class="p">)]],</span> <span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">2</span><span class="p">),</span> <span class="n">QQ</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">A</span><span class="o">.</span><span class="n">lu</span><span class="p">()</span>
<span class="go">(DomainMatrix([[1, 0], [2, 1]], (2, 2), QQ), DomainMatrix([[1, -1], [0, 0]], (2, 2), QQ), [])</span>
</pre></div>
</div>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<p><a class="reference internal" href="#sympy.polys.matrices.domainmatrix.DomainMatrix.lu_solve" title="sympy.polys.matrices.domainmatrix.DomainMatrix.lu_solve"><code class="xref py py-obj docutils literal notranslate"><span class="pre">lu_solve</span></code></a></p>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.matrices.domainmatrix.DomainMatrix.lu_solve">
<span class="sig-name descname"><span class="pre">lu_solve</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">rhs</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/matrices/domainmatrix.py#L1317-L1367"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.matrices.domainmatrix.DomainMatrix.lu_solve" title="Permalink to this definition">¶</a></dt>
<dd><p>Solver for DomainMatrix x in the A*x = B</p>
<dl class="field-list">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>rhs</strong> : DomainMatrix B</p>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>DomainMatrix</p>
<blockquote>
<div><p>x in A*x = B</p>
</div></blockquote>
</dd>
<dt class="field-odd">Raises</dt>
<dd class="field-odd"><p><strong>ShapeError</strong></p>
<blockquote>
<div><p>If the DomainMatrix A and rhs have different number of rows</p>
</div></blockquote>
<p><strong>ValueError</strong></p>
<blockquote>
<div><p>If the domain of DomainMatrix A not a Field</p>
</div></blockquote>
</dd>
</dl>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">QQ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.matrices</span> <span class="kn">import</span> <span class="n">DomainMatrix</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">A</span> <span class="o">=</span> <span class="n">DomainMatrix</span><span class="p">([</span>
<span class="gp">... </span>   <span class="p">[</span><span class="n">QQ</span><span class="p">(</span><span class="mi">1</span><span class="p">),</span> <span class="n">QQ</span><span class="p">(</span><span class="mi">2</span><span class="p">)],</span>
<span class="gp">... </span>   <span class="p">[</span><span class="n">QQ</span><span class="p">(</span><span class="mi">3</span><span class="p">),</span> <span class="n">QQ</span><span class="p">(</span><span class="mi">4</span><span class="p">)]],</span> <span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">2</span><span class="p">),</span> <span class="n">QQ</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">B</span> <span class="o">=</span> <span class="n">DomainMatrix</span><span class="p">([</span>
<span class="gp">... </span>   <span class="p">[</span><span class="n">QQ</span><span class="p">(</span><span class="mi">1</span><span class="p">),</span> <span class="n">QQ</span><span class="p">(</span><span class="mi">1</span><span class="p">)],</span>
<span class="gp">... </span>   <span class="p">[</span><span class="n">QQ</span><span class="p">(</span><span class="mi">0</span><span class="p">),</span> <span class="n">QQ</span><span class="p">(</span><span class="mi">1</span><span class="p">)]],</span> <span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">2</span><span class="p">),</span> <span class="n">QQ</span><span class="p">)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">A</span><span class="o">.</span><span class="n">lu_solve</span><span class="p">(</span><span class="n">B</span><span class="p">)</span>
<span class="go">DomainMatrix([[-2, -1], [3/2, 1]], (2, 2), QQ)</span>
</pre></div>
</div>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<p><a class="reference internal" href="#sympy.polys.matrices.domainmatrix.DomainMatrix.lu" title="sympy.polys.matrices.domainmatrix.DomainMatrix.lu"><code class="xref py py-obj docutils literal notranslate"><span class="pre">lu</span></code></a></p>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.matrices.domainmatrix.DomainMatrix.matmul">
<span class="sig-name descname"><span class="pre">matmul</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">B</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/matrices/domainmatrix.py#L922-L961"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.matrices.domainmatrix.DomainMatrix.matmul" title="Permalink to this definition">¶</a></dt>
<dd><p>Performs matrix multiplication of two DomainMatrix matrices</p>
<dl class="field-list">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>A, B: DomainMatrix</strong></p>
<blockquote>
<div><p>to multiply</p>
</div></blockquote>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>DomainMatrix</p>
<blockquote>
<div><p>DomainMatrix after multiplication</p>
</div></blockquote>
</dd>
</dl>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.matrices</span> <span class="kn">import</span> <span class="n">DomainMatrix</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">A</span> <span class="o">=</span> <span class="n">DomainMatrix</span><span class="p">([</span>
<span class="gp">... </span>   <span class="p">[</span><span class="n">ZZ</span><span class="p">(</span><span class="mi">1</span><span class="p">),</span> <span class="n">ZZ</span><span class="p">(</span><span class="mi">2</span><span class="p">)],</span>
<span class="gp">... </span>   <span class="p">[</span><span class="n">ZZ</span><span class="p">(</span><span class="mi">3</span><span class="p">),</span> <span class="n">ZZ</span><span class="p">(</span><span class="mi">4</span><span class="p">)]],</span> <span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">2</span><span class="p">),</span> <span class="n">ZZ</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">B</span> <span class="o">=</span> <span class="n">DomainMatrix</span><span class="p">([</span>
<span class="gp">... </span>   <span class="p">[</span><span class="n">ZZ</span><span class="p">(</span><span class="mi">1</span><span class="p">),</span> <span class="n">ZZ</span><span class="p">(</span><span class="mi">1</span><span class="p">)],</span>
<span class="gp">... </span>   <span class="p">[</span><span class="n">ZZ</span><span class="p">(</span><span class="mi">0</span><span class="p">),</span> <span class="n">ZZ</span><span class="p">(</span><span class="mi">1</span><span class="p">)]],</span> <span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">2</span><span class="p">),</span> <span class="n">ZZ</span><span class="p">)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">A</span><span class="o">.</span><span class="n">matmul</span><span class="p">(</span><span class="n">B</span><span class="p">)</span>
<span class="go">DomainMatrix([[1, 3], [3, 7]], (2, 2), ZZ)</span>
</pre></div>
</div>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<p><a class="reference internal" href="#sympy.polys.matrices.domainmatrix.DomainMatrix.mul" title="sympy.polys.matrices.domainmatrix.DomainMatrix.mul"><code class="xref py py-obj docutils literal notranslate"><span class="pre">mul</span></code></a>, <a class="reference internal" href="#sympy.polys.matrices.domainmatrix.DomainMatrix.pow" title="sympy.polys.matrices.domainmatrix.DomainMatrix.pow"><code class="xref py py-obj docutils literal notranslate"><span class="pre">pow</span></code></a>, <a class="reference internal" href="#sympy.polys.matrices.domainmatrix.DomainMatrix.add" title="sympy.polys.matrices.domainmatrix.DomainMatrix.add"><code class="xref py py-obj docutils literal notranslate"><span class="pre">add</span></code></a>, <a class="reference internal" href="#sympy.polys.matrices.domainmatrix.DomainMatrix.sub" title="sympy.polys.matrices.domainmatrix.DomainMatrix.sub"><code class="xref py py-obj docutils literal notranslate"><span class="pre">sub</span></code></a></p>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.matrices.domainmatrix.DomainMatrix.mul">
<span class="sig-name descname"><span class="pre">mul</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">b</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/matrices/domainmatrix.py#L875-L917"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.matrices.domainmatrix.DomainMatrix.mul" title="Permalink to this definition">¶</a></dt>
<dd><p>Performs term by term multiplication for the second DomainMatrix
w.r.t first DomainMatrix. Returns a DomainMatrix whose rows are
list of DomainMatrix matrices created after term by term multiplication.</p>
<dl class="field-list">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>A, B: DomainMatrix</strong></p>
<blockquote>
<div><p>matrices to multiply term-wise</p>
</div></blockquote>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>DomainMatrix</p>
<blockquote>
<div><p>DomainMatrix after term by term multiplication</p>
</div></blockquote>
</dd>
</dl>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.matrices</span> <span class="kn">import</span> <span class="n">DomainMatrix</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">A</span> <span class="o">=</span> <span class="n">DomainMatrix</span><span class="p">([</span>
<span class="gp">... </span>   <span class="p">[</span><span class="n">ZZ</span><span class="p">(</span><span class="mi">1</span><span class="p">),</span> <span class="n">ZZ</span><span class="p">(</span><span class="mi">2</span><span class="p">)],</span>
<span class="gp">... </span>   <span class="p">[</span><span class="n">ZZ</span><span class="p">(</span><span class="mi">3</span><span class="p">),</span> <span class="n">ZZ</span><span class="p">(</span><span class="mi">4</span><span class="p">)]],</span> <span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">2</span><span class="p">),</span> <span class="n">ZZ</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">B</span> <span class="o">=</span> <span class="n">DomainMatrix</span><span class="p">([</span>
<span class="gp">... </span>   <span class="p">[</span><span class="n">ZZ</span><span class="p">(</span><span class="mi">1</span><span class="p">),</span> <span class="n">ZZ</span><span class="p">(</span><span class="mi">1</span><span class="p">)],</span>
<span class="gp">... </span>   <span class="p">[</span><span class="n">ZZ</span><span class="p">(</span><span class="mi">0</span><span class="p">),</span> <span class="n">ZZ</span><span class="p">(</span><span class="mi">1</span><span class="p">)]],</span> <span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">2</span><span class="p">),</span> <span class="n">ZZ</span><span class="p">)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">A</span><span class="o">.</span><span class="n">mul</span><span class="p">(</span><span class="n">B</span><span class="p">)</span>
<span class="go">DomainMatrix([[DomainMatrix([[1, 1], [0, 1]], (2, 2), ZZ),</span>
<span class="go">DomainMatrix([[2, 2], [0, 2]], (2, 2), ZZ)],</span>
<span class="go">[DomainMatrix([[3, 3], [0, 3]], (2, 2), ZZ),</span>
<span class="go">DomainMatrix([[4, 4], [0, 4]], (2, 2), ZZ)]], (2, 2), ZZ)</span>
</pre></div>
</div>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<p><a class="reference internal" href="#sympy.polys.matrices.domainmatrix.DomainMatrix.matmul" title="sympy.polys.matrices.domainmatrix.DomainMatrix.matmul"><code class="xref py py-obj docutils literal notranslate"><span class="pre">matmul</span></code></a></p>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.matrices.domainmatrix.DomainMatrix.neg">
<span class="sig-name descname"><span class="pre">neg</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/matrices/domainmatrix.py#L845-L873"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.matrices.domainmatrix.DomainMatrix.neg" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns the negative of DomainMatrix</p>
<dl class="field-list">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>A</strong> : Represents a DomainMatrix</p>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>DomainMatrix</p>
<blockquote>
<div><p>DomainMatrix after Negation</p>
</div></blockquote>
</dd>
</dl>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.matrices</span> <span class="kn">import</span> <span class="n">DomainMatrix</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">A</span> <span class="o">=</span> <span class="n">DomainMatrix</span><span class="p">([</span>
<span class="gp">... </span>   <span class="p">[</span><span class="n">ZZ</span><span class="p">(</span><span class="mi">1</span><span class="p">),</span> <span class="n">ZZ</span><span class="p">(</span><span class="mi">2</span><span class="p">)],</span>
<span class="gp">... </span>   <span class="p">[</span><span class="n">ZZ</span><span class="p">(</span><span class="mi">3</span><span class="p">),</span> <span class="n">ZZ</span><span class="p">(</span><span class="mi">4</span><span class="p">)]],</span> <span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">2</span><span class="p">),</span> <span class="n">ZZ</span><span class="p">)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">A</span><span class="o">.</span><span class="n">neg</span><span class="p">()</span>
<span class="go">DomainMatrix([[-1, -2], [-3, -4]], (2, 2), ZZ)</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.matrices.domainmatrix.DomainMatrix.nullspace">
<span class="sig-name descname"><span class="pre">nullspace</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/matrices/domainmatrix.py#L1173-L1197"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.matrices.domainmatrix.DomainMatrix.nullspace" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns the Null Space for the DomainMatrix</p>
<dl class="field-list">
<dt class="field-odd">Returns</dt>
<dd class="field-odd"><p>DomainMatrix</p>
<blockquote>
<div><p>Null Space of the DomainMatrix</p>
</div></blockquote>
</dd>
</dl>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">QQ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.matrices</span> <span class="kn">import</span> <span class="n">DomainMatrix</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">A</span> <span class="o">=</span> <span class="n">DomainMatrix</span><span class="p">([</span>
<span class="gp">... </span>   <span class="p">[</span><span class="n">QQ</span><span class="p">(</span><span class="mi">1</span><span class="p">),</span> <span class="n">QQ</span><span class="p">(</span><span class="o">-</span><span class="mi">1</span><span class="p">)],</span>
<span class="gp">... </span>   <span class="p">[</span><span class="n">QQ</span><span class="p">(</span><span class="mi">2</span><span class="p">),</span> <span class="n">QQ</span><span class="p">(</span><span class="o">-</span><span class="mi">2</span><span class="p">)]],</span> <span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">2</span><span class="p">),</span> <span class="n">QQ</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">A</span><span class="o">.</span><span class="n">nullspace</span><span class="p">()</span>
<span class="go">DomainMatrix([[1, 1]], (1, 2), QQ)</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.matrices.domainmatrix.DomainMatrix.ones">
<em class="property"><span class="pre">classmethod</span> </em><span class="sig-name descname"><span class="pre">ones</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">shape</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">domain</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/matrices/domainmatrix.py#L1471-L1484"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.matrices.domainmatrix.DomainMatrix.ones" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns a zero DomainMatrix of size shape, belonging to the specified domain</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.matrices</span> <span class="kn">import</span> <span class="n">DomainMatrix</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">QQ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">DomainMatrix</span><span class="o">.</span><span class="n">ones</span><span class="p">((</span><span class="mi">2</span><span class="p">,</span><span class="mi">3</span><span class="p">),</span> <span class="n">QQ</span><span class="p">)</span>
<span class="go">DomainMatrix([[1, 1, 1], [1, 1, 1]], (2, 3), QQ)</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.matrices.domainmatrix.DomainMatrix.pow">
<span class="sig-name descname"><span class="pre">pow</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">n</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/matrices/domainmatrix.py#L999-L1053"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.matrices.domainmatrix.DomainMatrix.pow" title="Permalink to this definition">¶</a></dt>
<dd><p>Computes A**n</p>
<dl class="field-list">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>A</strong> : DomainMatrix</p>
<p><strong>n</strong> : exponent for A</p>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>DomainMatrix</p>
<blockquote>
<div><p>DomainMatrix on computing A**n</p>
</div></blockquote>
</dd>
<dt class="field-odd">Raises</dt>
<dd class="field-odd"><p><strong>NotImplementedError</strong></p>
<blockquote>
<div><p>if n is negative.</p>
</div></blockquote>
</dd>
</dl>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.matrices</span> <span class="kn">import</span> <span class="n">DomainMatrix</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">A</span> <span class="o">=</span> <span class="n">DomainMatrix</span><span class="p">([</span>
<span class="gp">... </span>   <span class="p">[</span><span class="n">ZZ</span><span class="p">(</span><span class="mi">1</span><span class="p">),</span> <span class="n">ZZ</span><span class="p">(</span><span class="mi">1</span><span class="p">)],</span>
<span class="gp">... </span>   <span class="p">[</span><span class="n">ZZ</span><span class="p">(</span><span class="mi">0</span><span class="p">),</span> <span class="n">ZZ</span><span class="p">(</span><span class="mi">1</span><span class="p">)]],</span> <span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">2</span><span class="p">),</span> <span class="n">ZZ</span><span class="p">)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">A</span><span class="o">.</span><span class="n">pow</span><span class="p">(</span><span class="mi">2</span><span class="p">)</span>
<span class="go">DomainMatrix([[1, 2], [0, 1]], (2, 2), ZZ)</span>
</pre></div>
</div>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<p><a class="reference internal" href="#sympy.polys.matrices.domainmatrix.DomainMatrix.matmul" title="sympy.polys.matrices.domainmatrix.DomainMatrix.matmul"><code class="xref py py-obj docutils literal notranslate"><span class="pre">matmul</span></code></a></p>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.matrices.domainmatrix.DomainMatrix.rref">
<span class="sig-name descname"><span class="pre">rref</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/matrices/domainmatrix.py#L1130-L1171"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.matrices.domainmatrix.DomainMatrix.rref" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns reduced-row echelon form and list of pivots for the DomainMatrix</p>
<dl class="field-list">
<dt class="field-odd">Returns</dt>
<dd class="field-odd"><p>(DomainMatrix, list)</p>
<blockquote>
<div><p>reduced-row echelon form and list of pivots for the DomainMatrix</p>
</div></blockquote>
</dd>
<dt class="field-even">Raises</dt>
<dd class="field-even"><p><strong>ValueError</strong></p>
<blockquote>
<div><p>If the domain of DomainMatrix not a Field</p>
</div></blockquote>
</dd>
</dl>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">QQ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.matrices</span> <span class="kn">import</span> <span class="n">DomainMatrix</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">A</span> <span class="o">=</span> <span class="n">DomainMatrix</span><span class="p">([</span>
<span class="gp">... </span>    <span class="p">[</span><span class="n">QQ</span><span class="p">(</span><span class="mi">2</span><span class="p">),</span> <span class="n">QQ</span><span class="p">(</span><span class="o">-</span><span class="mi">1</span><span class="p">),</span> <span class="n">QQ</span><span class="p">(</span><span class="mi">0</span><span class="p">)],</span>
<span class="gp">... </span>    <span class="p">[</span><span class="n">QQ</span><span class="p">(</span><span class="o">-</span><span class="mi">1</span><span class="p">),</span> <span class="n">QQ</span><span class="p">(</span><span class="mi">2</span><span class="p">),</span> <span class="n">QQ</span><span class="p">(</span><span class="o">-</span><span class="mi">1</span><span class="p">)],</span>
<span class="gp">... </span>    <span class="p">[</span><span class="n">QQ</span><span class="p">(</span><span class="mi">0</span><span class="p">),</span> <span class="n">QQ</span><span class="p">(</span><span class="mi">0</span><span class="p">),</span> <span class="n">QQ</span><span class="p">(</span><span class="mi">2</span><span class="p">)]],</span> <span class="p">(</span><span class="mi">3</span><span class="p">,</span> <span class="mi">3</span><span class="p">),</span> <span class="n">QQ</span><span class="p">)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">rref_matrix</span><span class="p">,</span> <span class="n">rref_pivots</span> <span class="o">=</span> <span class="n">A</span><span class="o">.</span><span class="n">rref</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">rref_matrix</span>
<span class="go">DomainMatrix([[1, 0, 0], [0, 1, 0], [0, 0, 1]], (3, 3), QQ)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">rref_pivots</span>
<span class="go">(0, 1, 2)</span>
</pre></div>
</div>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<p><a class="reference internal" href="#sympy.polys.matrices.domainmatrix.DomainMatrix.convert_to" title="sympy.polys.matrices.domainmatrix.DomainMatrix.convert_to"><code class="xref py py-obj docutils literal notranslate"><span class="pre">convert_to</span></code></a>, <a class="reference internal" href="#sympy.polys.matrices.domainmatrix.DomainMatrix.lu" title="sympy.polys.matrices.domainmatrix.DomainMatrix.lu"><code class="xref py py-obj docutils literal notranslate"><span class="pre">lu</span></code></a></p>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.matrices.domainmatrix.DomainMatrix.scc">
<span class="sig-name descname"><span class="pre">scc</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/matrices/domainmatrix.py#L1055-L1128"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.matrices.domainmatrix.DomainMatrix.scc" title="Permalink to this definition">¶</a></dt>
<dd><p>Compute the strongly connected components of a DomainMatrix</p>
<dl class="field-list">
<dt class="field-odd">Returns</dt>
<dd class="field-odd"><p>List of lists of integers</p>
<blockquote>
<div><p>Each list represents a strongly connected component.</p>
</div></blockquote>
</dd>
</dl>
<p class="rubric">Explanation</p>
<p>A square matrix can be considered as the adjacency matrix for a
directed graph where the row and column indices are the vertices. In
this graph if there is an edge from vertex <code class="docutils literal notranslate"><span class="pre">i</span></code> to vertex <code class="docutils literal notranslate"><span class="pre">j</span></code> if
<code class="docutils literal notranslate"><span class="pre">M[i,</span> <span class="pre">j]</span></code> is nonzero. This routine computes the strongly connected
components of that graph which are subsets of the rows and columns that
are connected by some nonzero element of the matrix. The strongly
connected components are useful because many operations such as the
determinant can be computed by working with the submatrices
corresponding to each component.</p>
<p class="rubric">Examples</p>
<p>Find the strongly connected components of a matrix:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.matrices</span> <span class="kn">import</span> <span class="n">DomainMatrix</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">M</span> <span class="o">=</span> <span class="n">DomainMatrix</span><span class="p">([[</span><span class="n">ZZ</span><span class="p">(</span><span class="mi">1</span><span class="p">),</span> <span class="n">ZZ</span><span class="p">(</span><span class="mi">0</span><span class="p">),</span> <span class="n">ZZ</span><span class="p">(</span><span class="mi">2</span><span class="p">)],</span>
<span class="gp">... </span>                  <span class="p">[</span><span class="n">ZZ</span><span class="p">(</span><span class="mi">0</span><span class="p">),</span> <span class="n">ZZ</span><span class="p">(</span><span class="mi">3</span><span class="p">),</span> <span class="n">ZZ</span><span class="p">(</span><span class="mi">0</span><span class="p">)],</span>
<span class="gp">... </span>                  <span class="p">[</span><span class="n">ZZ</span><span class="p">(</span><span class="mi">4</span><span class="p">),</span> <span class="n">ZZ</span><span class="p">(</span><span class="mi">6</span><span class="p">),</span> <span class="n">ZZ</span><span class="p">(</span><span class="mi">5</span><span class="p">)]],</span> <span class="p">(</span><span class="mi">3</span><span class="p">,</span> <span class="mi">3</span><span class="p">),</span> <span class="n">ZZ</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">M</span><span class="o">.</span><span class="n">scc</span><span class="p">()</span>
<span class="go">[[1], [0, 2]]</span>
</pre></div>
</div>
<p>Compute the determinant from the components:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">MM</span> <span class="o">=</span> <span class="n">M</span><span class="o">.</span><span class="n">to_Matrix</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">MM</span>
<span class="go">Matrix([</span>
<span class="go">[1, 0, 2],</span>
<span class="go">[0, 3, 0],</span>
<span class="go">[4, 6, 5]])</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">MM</span><span class="p">[[</span><span class="mi">1</span><span class="p">],</span> <span class="p">[</span><span class="mi">1</span><span class="p">]]</span>
<span class="go">Matrix([[3]])</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">MM</span><span class="p">[[</span><span class="mi">0</span><span class="p">,</span> <span class="mi">2</span><span class="p">],</span> <span class="p">[</span><span class="mi">0</span><span class="p">,</span> <span class="mi">2</span><span class="p">]]</span>
<span class="go">Matrix([</span>
<span class="go">[1, 2],</span>
<span class="go">[4, 5]])</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">MM</span><span class="o">.</span><span class="n">det</span><span class="p">()</span>
<span class="go">-9</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">MM</span><span class="p">[[</span><span class="mi">1</span><span class="p">],</span> <span class="p">[</span><span class="mi">1</span><span class="p">]]</span><span class="o">.</span><span class="n">det</span><span class="p">()</span> <span class="o">*</span> <span class="n">MM</span><span class="p">[[</span><span class="mi">0</span><span class="p">,</span> <span class="mi">2</span><span class="p">],</span> <span class="p">[</span><span class="mi">0</span><span class="p">,</span> <span class="mi">2</span><span class="p">]]</span><span class="o">.</span><span class="n">det</span><span class="p">()</span>
<span class="go">-9</span>
</pre></div>
</div>
<p>The components are given in reverse topological order and represent a
permutation of the rows and columns that will bring the matrix into
block lower-triangular form:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">MM</span><span class="p">[[</span><span class="mi">1</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">2</span><span class="p">],</span> <span class="p">[</span><span class="mi">1</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">2</span><span class="p">]]</span>
<span class="go">Matrix([</span>
<span class="go">[3, 0, 0],</span>
<span class="go">[0, 1, 2],</span>
<span class="go">[6, 4, 5]])</span>
</pre></div>
</div>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<p><a class="reference internal" href="../matrices/matrices.html#sympy.matrices.matrices.MatrixBase.strongly_connected_components" title="sympy.matrices.matrices.MatrixBase.strongly_connected_components"><code class="xref py py-obj docutils literal notranslate"><span class="pre">sympy.matrices.matrices.MatrixBase.strongly_connected_components</span></code></a>, <a class="reference internal" href="../utilities/iterables.html#sympy.utilities.iterables.strongly_connected_components" title="sympy.utilities.iterables.strongly_connected_components"><code class="xref py py-obj docutils literal notranslate"><span class="pre">sympy.utilities.iterables.strongly_connected_components</span></code></a></p>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.matrices.domainmatrix.DomainMatrix.sub">
<span class="sig-name descname"><span class="pre">sub</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">B</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/matrices/domainmatrix.py#L796-L843"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.matrices.domainmatrix.DomainMatrix.sub" title="Permalink to this definition">¶</a></dt>
<dd><p>Subtracts two DomainMatrix matrices of the same Domain</p>
<dl class="field-list">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>A, B: DomainMatrix</strong></p>
<blockquote>
<div><p>matrices to substract</p>
</div></blockquote>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>DomainMatrix</p>
<blockquote>
<div><p>DomainMatrix after Substraction</p>
</div></blockquote>
</dd>
<dt class="field-odd">Raises</dt>
<dd class="field-odd"><p><strong>ShapeError</strong></p>
<blockquote>
<div><p>If the dimensions of the two DomainMatrix are not equal</p>
</div></blockquote>
<p><strong>ValueError</strong></p>
<blockquote>
<div><p>If the domain of the two DomainMatrix are not same</p>
</div></blockquote>
</dd>
</dl>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.matrices</span> <span class="kn">import</span> <span class="n">DomainMatrix</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">A</span> <span class="o">=</span> <span class="n">DomainMatrix</span><span class="p">([</span>
<span class="gp">... </span>   <span class="p">[</span><span class="n">ZZ</span><span class="p">(</span><span class="mi">1</span><span class="p">),</span> <span class="n">ZZ</span><span class="p">(</span><span class="mi">2</span><span class="p">)],</span>
<span class="gp">... </span>   <span class="p">[</span><span class="n">ZZ</span><span class="p">(</span><span class="mi">3</span><span class="p">),</span> <span class="n">ZZ</span><span class="p">(</span><span class="mi">4</span><span class="p">)]],</span> <span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">2</span><span class="p">),</span> <span class="n">ZZ</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">B</span> <span class="o">=</span> <span class="n">DomainMatrix</span><span class="p">([</span>
<span class="gp">... </span>   <span class="p">[</span><span class="n">ZZ</span><span class="p">(</span><span class="mi">4</span><span class="p">),</span> <span class="n">ZZ</span><span class="p">(</span><span class="mi">3</span><span class="p">)],</span>
<span class="gp">... </span>   <span class="p">[</span><span class="n">ZZ</span><span class="p">(</span><span class="mi">2</span><span class="p">),</span> <span class="n">ZZ</span><span class="p">(</span><span class="mi">1</span><span class="p">)]],</span> <span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">2</span><span class="p">),</span> <span class="n">ZZ</span><span class="p">)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">A</span><span class="o">.</span><span class="n">sub</span><span class="p">(</span><span class="n">B</span><span class="p">)</span>
<span class="go">DomainMatrix([[-3, -1], [1, 3]], (2, 2), ZZ)</span>
</pre></div>
</div>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<p><a class="reference internal" href="#sympy.polys.matrices.domainmatrix.DomainMatrix.add" title="sympy.polys.matrices.domainmatrix.DomainMatrix.add"><code class="xref py py-obj docutils literal notranslate"><span class="pre">add</span></code></a>, <a class="reference internal" href="#sympy.polys.matrices.domainmatrix.DomainMatrix.matmul" title="sympy.polys.matrices.domainmatrix.DomainMatrix.matmul"><code class="xref py py-obj docutils literal notranslate"><span class="pre">matmul</span></code></a></p>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.matrices.domainmatrix.DomainMatrix.to_Matrix">
<span class="sig-name descname"><span class="pre">to_Matrix</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/matrices/domainmatrix.py#L552-L585"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.matrices.domainmatrix.DomainMatrix.to_Matrix" title="Permalink to this definition">¶</a></dt>
<dd><p>Convert DomainMatrix to Matrix</p>
<dl class="field-list">
<dt class="field-odd">Returns</dt>
<dd class="field-odd"><p>Matrix</p>
<blockquote>
<div><p>MutableDenseMatrix for the DomainMatrix</p>
</div></blockquote>
</dd>
</dl>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.matrices</span> <span class="kn">import</span> <span class="n">DomainMatrix</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">A</span> <span class="o">=</span> <span class="n">DomainMatrix</span><span class="p">([</span>
<span class="gp">... </span>   <span class="p">[</span><span class="n">ZZ</span><span class="p">(</span><span class="mi">1</span><span class="p">),</span> <span class="n">ZZ</span><span class="p">(</span><span class="mi">2</span><span class="p">)],</span>
<span class="gp">... </span>   <span class="p">[</span><span class="n">ZZ</span><span class="p">(</span><span class="mi">3</span><span class="p">),</span> <span class="n">ZZ</span><span class="p">(</span><span class="mi">4</span><span class="p">)]],</span> <span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">2</span><span class="p">),</span> <span class="n">ZZ</span><span class="p">)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">A</span><span class="o">.</span><span class="n">to_Matrix</span><span class="p">()</span>
<span class="go">Matrix([</span>
<span class="go">    [1, 2],</span>
<span class="go">    [3, 4]])</span>
</pre></div>
</div>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<p><a class="reference internal" href="#sympy.polys.matrices.domainmatrix.DomainMatrix.from_Matrix" title="sympy.polys.matrices.domainmatrix.DomainMatrix.from_Matrix"><code class="xref py py-obj docutils literal notranslate"><span class="pre">from_Matrix</span></code></a></p>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.matrices.domainmatrix.DomainMatrix.to_dense">
<span class="sig-name descname"><span class="pre">to_dense</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/matrices/domainmatrix.py#L444-L464"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.matrices.domainmatrix.DomainMatrix.to_dense" title="Permalink to this definition">¶</a></dt>
<dd><p>Return a dense DomainMatrix representation of <em>self</em>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.matrices</span> <span class="kn">import</span> <span class="n">DomainMatrix</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">QQ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">A</span> <span class="o">=</span> <span class="n">DomainMatrix</span><span class="p">({</span><span class="mi">0</span><span class="p">:</span> <span class="p">{</span><span class="mi">0</span><span class="p">:</span> <span class="mi">1</span><span class="p">},</span> <span class="mi">1</span><span class="p">:</span> <span class="p">{</span><span class="mi">1</span><span class="p">:</span> <span class="mi">2</span><span class="p">}},</span> <span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">2</span><span class="p">),</span> <span class="n">QQ</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">A</span><span class="o">.</span><span class="n">rep</span>
<span class="go">{0: {0: 1}, 1: {1: 2}}</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">B</span> <span class="o">=</span> <span class="n">A</span><span class="o">.</span><span class="n">to_dense</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">B</span><span class="o">.</span><span class="n">rep</span>
<span class="go">[[1, 0], [0, 2]]</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.matrices.domainmatrix.DomainMatrix.to_field">
<span class="sig-name descname"><span class="pre">to_field</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/matrices/domainmatrix.py#L397-L421"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.matrices.domainmatrix.DomainMatrix.to_field" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns a DomainMatrix with the appropriate field</p>
<dl class="field-list">
<dt class="field-odd">Returns</dt>
<dd class="field-odd"><p>DomainMatrix</p>
<blockquote>
<div><p>DomainMatrix with the appropriate field</p>
</div></blockquote>
</dd>
</dl>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.matrices</span> <span class="kn">import</span> <span class="n">DomainMatrix</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">A</span> <span class="o">=</span> <span class="n">DomainMatrix</span><span class="p">([</span>
<span class="gp">... </span>   <span class="p">[</span><span class="n">ZZ</span><span class="p">(</span><span class="mi">1</span><span class="p">),</span> <span class="n">ZZ</span><span class="p">(</span><span class="mi">2</span><span class="p">)],</span>
<span class="gp">... </span>   <span class="p">[</span><span class="n">ZZ</span><span class="p">(</span><span class="mi">3</span><span class="p">),</span> <span class="n">ZZ</span><span class="p">(</span><span class="mi">4</span><span class="p">)]],</span> <span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">2</span><span class="p">),</span> <span class="n">ZZ</span><span class="p">)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">A</span><span class="o">.</span><span class="n">to_field</span><span class="p">()</span>
<span class="go">DomainMatrix([[1, 2], [3, 4]], (2, 2), QQ)</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.matrices.domainmatrix.DomainMatrix.to_sparse">
<span class="sig-name descname"><span class="pre">to_sparse</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/matrices/domainmatrix.py#L423-L442"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.matrices.domainmatrix.DomainMatrix.to_sparse" title="Permalink to this definition">¶</a></dt>
<dd><p>Return a sparse DomainMatrix representation of <em>self</em>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.matrices</span> <span class="kn">import</span> <span class="n">DomainMatrix</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">QQ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">A</span> <span class="o">=</span> <span class="n">DomainMatrix</span><span class="p">([[</span><span class="mi">1</span><span class="p">,</span> <span class="mi">0</span><span class="p">],[</span><span class="mi">0</span><span class="p">,</span> <span class="mi">2</span><span class="p">]],</span> <span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">2</span><span class="p">),</span> <span class="n">QQ</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">A</span><span class="o">.</span><span class="n">rep</span>
<span class="go">[[1, 0], [0, 2]]</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">B</span> <span class="o">=</span> <span class="n">A</span><span class="o">.</span><span class="n">to_sparse</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">B</span><span class="o">.</span><span class="n">rep</span>
<span class="go">{0: {0: 1}, 1: {1: 2}}</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.matrices.domainmatrix.DomainMatrix.transpose">
<span class="sig-name descname"><span class="pre">transpose</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/matrices/domainmatrix.py#L599-L601"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.matrices.domainmatrix.DomainMatrix.transpose" title="Permalink to this definition">¶</a></dt>
<dd><p>Matrix transpose of <code class="docutils literal notranslate"><span class="pre">self</span></code></p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.matrices.domainmatrix.DomainMatrix.unify">
<span class="sig-name descname"><span class="pre">unify</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">others</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">fmt</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/matrices/domainmatrix.py#L493-L550"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.matrices.domainmatrix.DomainMatrix.unify" title="Permalink to this definition">¶</a></dt>
<dd><p>Unifies the domains and the format of self and other
matrices.</p>
<dl class="field-list">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>others</strong> : DomainMatrix</p>
<p><strong>fmt: string ‘dense’, ‘sparse’ or `None` (default)</strong></p>
<blockquote>
<div><p>The preferred format to convert to if self and other are not
already in the same format. If <span class="math notranslate nohighlight">\(None\)</span> or not specified then no
conversion if performed.</p>
</div></blockquote>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>Tuple[DomainMatrix]</p>
<blockquote>
<div><p>Matrices with unified domain and format</p>
</div></blockquote>
</dd>
</dl>
<p class="rubric">Examples</p>
<p>Unify the domain of DomainMatrix that have different domains:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">ZZ</span><span class="p">,</span> <span class="n">QQ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.matrices</span> <span class="kn">import</span> <span class="n">DomainMatrix</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">A</span> <span class="o">=</span> <span class="n">DomainMatrix</span><span class="p">([[</span><span class="n">ZZ</span><span class="p">(</span><span class="mi">1</span><span class="p">),</span> <span class="n">ZZ</span><span class="p">(</span><span class="mi">2</span><span class="p">)]],</span> <span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">),</span> <span class="n">ZZ</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">B</span> <span class="o">=</span> <span class="n">DomainMatrix</span><span class="p">([[</span><span class="n">QQ</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">),</span> <span class="n">QQ</span><span class="p">(</span><span class="mi">2</span><span class="p">)]],</span> <span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">),</span> <span class="n">QQ</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">Aq</span><span class="p">,</span> <span class="n">Bq</span> <span class="o">=</span> <span class="n">A</span><span class="o">.</span><span class="n">unify</span><span class="p">(</span><span class="n">B</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">Aq</span>
<span class="go">DomainMatrix([[1, 2]], (1, 2), QQ)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">Bq</span>
<span class="go">DomainMatrix([[1/2, 2]], (1, 2), QQ)</span>
</pre></div>
</div>
<p>Unify the format (dense or sparse):</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">A</span> <span class="o">=</span> <span class="n">DomainMatrix</span><span class="p">([[</span><span class="n">ZZ</span><span class="p">(</span><span class="mi">1</span><span class="p">),</span> <span class="n">ZZ</span><span class="p">(</span><span class="mi">2</span><span class="p">)]],</span> <span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">),</span> <span class="n">ZZ</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">B</span> <span class="o">=</span> <span class="n">DomainMatrix</span><span class="p">({</span><span class="mi">0</span><span class="p">:{</span><span class="mi">0</span><span class="p">:</span> <span class="n">ZZ</span><span class="p">(</span><span class="mi">1</span><span class="p">)}},</span> <span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">2</span><span class="p">),</span> <span class="n">ZZ</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">B</span><span class="o">.</span><span class="n">rep</span>
<span class="go">{0: {0: 1}}</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">A2</span><span class="p">,</span> <span class="n">B2</span> <span class="o">=</span> <span class="n">A</span><span class="o">.</span><span class="n">unify</span><span class="p">(</span><span class="n">B</span><span class="p">,</span> <span class="n">fmt</span><span class="o">=</span><span class="s1">&#39;dense&#39;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">B2</span><span class="o">.</span><span class="n">rep</span>
<span class="go">[[1, 0], [0, 0]]</span>
</pre></div>
</div>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<p><a class="reference internal" href="#sympy.polys.matrices.domainmatrix.DomainMatrix.convert_to" title="sympy.polys.matrices.domainmatrix.DomainMatrix.convert_to"><code class="xref py py-obj docutils literal notranslate"><span class="pre">convert_to</span></code></a>, <a class="reference internal" href="#sympy.polys.matrices.domainmatrix.DomainMatrix.to_dense" title="sympy.polys.matrices.domainmatrix.DomainMatrix.to_dense"><code class="xref py py-obj docutils literal notranslate"><span class="pre">to_dense</span></code></a>, <a class="reference internal" href="#sympy.polys.matrices.domainmatrix.DomainMatrix.to_sparse" title="sympy.polys.matrices.domainmatrix.DomainMatrix.to_sparse"><code class="xref py py-obj docutils literal notranslate"><span class="pre">to_sparse</span></code></a></p>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.matrices.domainmatrix.DomainMatrix.vstack">
<span class="sig-name descname"><span class="pre">vstack</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">B</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/matrices/domainmatrix.py#L649-L685"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.matrices.domainmatrix.DomainMatrix.vstack" title="Permalink to this definition">¶</a></dt>
<dd><p>Vertically stack the given matrices.</p>
<dl class="field-list">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>B: DomainMatrix</strong></p>
<blockquote>
<div><p>Matrices to stack vertically.</p>
</div></blockquote>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>DomainMatrix</p>
<blockquote>
<div><p>DomainMatrix by stacking vertically.</p>
</div></blockquote>
</dd>
</dl>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.matrices</span> <span class="kn">import</span> <span class="n">DomainMatrix</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">A</span> <span class="o">=</span> <span class="n">DomainMatrix</span><span class="p">([[</span><span class="n">ZZ</span><span class="p">(</span><span class="mi">1</span><span class="p">),</span> <span class="n">ZZ</span><span class="p">(</span><span class="mi">2</span><span class="p">)],</span> <span class="p">[</span><span class="n">ZZ</span><span class="p">(</span><span class="mi">3</span><span class="p">),</span> <span class="n">ZZ</span><span class="p">(</span><span class="mi">4</span><span class="p">)]],</span> <span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">2</span><span class="p">),</span> <span class="n">ZZ</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">B</span> <span class="o">=</span> <span class="n">DomainMatrix</span><span class="p">([[</span><span class="n">ZZ</span><span class="p">(</span><span class="mi">5</span><span class="p">),</span> <span class="n">ZZ</span><span class="p">(</span><span class="mi">6</span><span class="p">)],</span> <span class="p">[</span><span class="n">ZZ</span><span class="p">(</span><span class="mi">7</span><span class="p">),</span> <span class="n">ZZ</span><span class="p">(</span><span class="mi">8</span><span class="p">)]],</span> <span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">2</span><span class="p">),</span> <span class="n">ZZ</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">A</span><span class="o">.</span><span class="n">vstack</span><span class="p">(</span><span class="n">B</span><span class="p">)</span>
<span class="go">DomainMatrix([[1, 2], [3, 4], [5, 6], [7, 8]], (4, 2), ZZ)</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">C</span> <span class="o">=</span> <span class="n">DomainMatrix</span><span class="p">([[</span><span class="n">ZZ</span><span class="p">(</span><span class="mi">9</span><span class="p">),</span> <span class="n">ZZ</span><span class="p">(</span><span class="mi">10</span><span class="p">)],</span> <span class="p">[</span><span class="n">ZZ</span><span class="p">(</span><span class="mi">11</span><span class="p">),</span> <span class="n">ZZ</span><span class="p">(</span><span class="mi">12</span><span class="p">)]],</span> <span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">2</span><span class="p">),</span> <span class="n">ZZ</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">A</span><span class="o">.</span><span class="n">vstack</span><span class="p">(</span><span class="n">B</span><span class="p">,</span> <span class="n">C</span><span class="p">)</span>
<span class="go">DomainMatrix([[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12]], (6, 2), ZZ)</span>
</pre></div>
</div>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<p><a class="reference internal" href="#sympy.polys.matrices.domainmatrix.DomainMatrix.unify" title="sympy.polys.matrices.domainmatrix.DomainMatrix.unify"><code class="xref py py-obj docutils literal notranslate"><span class="pre">unify</span></code></a></p>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.matrices.domainmatrix.DomainMatrix.zeros">
<em class="property"><span class="pre">classmethod</span> </em><span class="sig-name descname"><span class="pre">zeros</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">shape</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">domain</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">*</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">fmt</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'sparse'</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/matrices/domainmatrix.py#L1456-L1469"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.matrices.domainmatrix.DomainMatrix.zeros" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns a zero DomainMatrix of size shape, belonging to the specified domain</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.matrices</span> <span class="kn">import</span> <span class="n">DomainMatrix</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">QQ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">DomainMatrix</span><span class="o">.</span><span class="n">zeros</span><span class="p">((</span><span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">),</span> <span class="n">QQ</span><span class="p">)</span>
<span class="go">DomainMatrix({}, (2, 3), QQ)</span>
</pre></div>
</div>
</dd></dl>

</dd></dl>

</section>
<section id="ddm-class-reference">
<h2>DDM Class Reference<a class="headerlink" href="#ddm-class-reference" title="Permalink to this headline">¶</a></h2>
<dl class="py class">
<dt class="sig sig-object py" id="sympy.polys.matrices.ddm.DDM">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">sympy.polys.matrices.ddm.</span></span><span class="sig-name descname"><span class="pre">DDM</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">rowslist</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">shape</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">domain</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/matrices/ddm.py#L83-L447"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.matrices.ddm.DDM" title="Permalink to this definition">¶</a></dt>
<dd><p>Dense matrix based on polys domain elements</p>
<p>This is a list subclass and is a wrapper for a list of lists that supports
basic matrix arithmetic +, -, <em>, *</em>.</p>
<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.matrices.ddm.DDM.add">
<span class="sig-name descname"><span class="pre">add</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">b</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/matrices/ddm.py#L232-L237"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.matrices.ddm.DDM.add" title="Permalink to this definition">¶</a></dt>
<dd><p>a + b</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.matrices.ddm.DDM.charpoly">
<span class="sig-name descname"><span class="pre">charpoly</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/matrices/ddm.py#L439-L447"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.matrices.ddm.DDM.charpoly" title="Permalink to this definition">¶</a></dt>
<dd><p>Coefficients of characteristic polynomial of a</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.matrices.ddm.DDM.det">
<span class="sig-name descname"><span class="pre">det</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/matrices/ddm.py#L397-L405"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.matrices.ddm.DDM.det" title="Permalink to this definition">¶</a></dt>
<dd><p>Determinant of a</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.matrices.ddm.DDM.hstack">
<span class="sig-name descname"><span class="pre">hstack</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">B</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/matrices/ddm.py#L277-L309"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.matrices.ddm.DDM.hstack" title="Permalink to this definition">¶</a></dt>
<dd><p>Horizontally stacks <a class="reference internal" href="#sympy.polys.matrices.ddm.DDM" title="sympy.polys.matrices.ddm.DDM"><code class="xref py py-class docutils literal notranslate"><span class="pre">DDM</span></code></a> matrices.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.matrices.sdm</span> <span class="kn">import</span> <span class="n">DDM</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">A</span> <span class="o">=</span> <span class="n">DDM</span><span class="p">([[</span><span class="n">ZZ</span><span class="p">(</span><span class="mi">1</span><span class="p">),</span> <span class="n">ZZ</span><span class="p">(</span><span class="mi">2</span><span class="p">)],</span> <span class="p">[</span><span class="n">ZZ</span><span class="p">(</span><span class="mi">3</span><span class="p">),</span> <span class="n">ZZ</span><span class="p">(</span><span class="mi">4</span><span class="p">)]],</span> <span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">2</span><span class="p">),</span> <span class="n">ZZ</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">B</span> <span class="o">=</span> <span class="n">DDM</span><span class="p">([[</span><span class="n">ZZ</span><span class="p">(</span><span class="mi">5</span><span class="p">),</span> <span class="n">ZZ</span><span class="p">(</span><span class="mi">6</span><span class="p">)],</span> <span class="p">[</span><span class="n">ZZ</span><span class="p">(</span><span class="mi">7</span><span class="p">),</span> <span class="n">ZZ</span><span class="p">(</span><span class="mi">8</span><span class="p">)]],</span> <span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">2</span><span class="p">),</span> <span class="n">ZZ</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">A</span><span class="o">.</span><span class="n">hstack</span><span class="p">(</span><span class="n">B</span><span class="p">)</span>
<span class="go">[[1, 2, 5, 6], [3, 4, 7, 8]]</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">C</span> <span class="o">=</span> <span class="n">DDM</span><span class="p">([[</span><span class="n">ZZ</span><span class="p">(</span><span class="mi">9</span><span class="p">),</span> <span class="n">ZZ</span><span class="p">(</span><span class="mi">10</span><span class="p">)],</span> <span class="p">[</span><span class="n">ZZ</span><span class="p">(</span><span class="mi">11</span><span class="p">),</span> <span class="n">ZZ</span><span class="p">(</span><span class="mi">12</span><span class="p">)]],</span> <span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">2</span><span class="p">),</span> <span class="n">ZZ</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">A</span><span class="o">.</span><span class="n">hstack</span><span class="p">(</span><span class="n">B</span><span class="p">,</span> <span class="n">C</span><span class="p">)</span>
<span class="go">[[1, 2, 5, 6, 9, 10], [3, 4, 7, 8, 11, 12]]</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.matrices.ddm.DDM.inv">
<span class="sig-name descname"><span class="pre">inv</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/matrices/ddm.py#L407-L415"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.matrices.ddm.DDM.inv" title="Permalink to this definition">¶</a></dt>
<dd><p>Inverse of a</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.matrices.ddm.DDM.lu">
<span class="sig-name descname"><span class="pre">lu</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/matrices/ddm.py#L417-L426"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.matrices.ddm.DDM.lu" title="Permalink to this definition">¶</a></dt>
<dd><p>L, U decomposition of a</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.matrices.ddm.DDM.lu_solve">
<span class="sig-name descname"><span class="pre">lu_solve</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">b</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/matrices/ddm.py#L428-L437"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.matrices.ddm.DDM.lu_solve" title="Permalink to this definition">¶</a></dt>
<dd><p>x where a*x = b</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.matrices.ddm.DDM.matmul">
<span class="sig-name descname"><span class="pre">matmul</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">b</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/matrices/ddm.py#L262-L269"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.matrices.ddm.DDM.matmul" title="Permalink to this definition">¶</a></dt>
<dd><p>a &#64; b (matrix product)</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.matrices.ddm.DDM.neg">
<span class="sig-name descname"><span class="pre">neg</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/matrices/ddm.py#L246-L250"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.matrices.ddm.DDM.neg" title="Permalink to this definition">¶</a></dt>
<dd><p>-a</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.matrices.ddm.DDM.rref">
<span class="sig-name descname"><span class="pre">rref</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/matrices/ddm.py#L368-L374"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.matrices.ddm.DDM.rref" title="Permalink to this definition">¶</a></dt>
<dd><p>Reduced-row echelon form of a and list of pivots</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.matrices.ddm.DDM.scc">
<span class="sig-name descname"><span class="pre">scc</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/matrices/ddm.py#L348-L366"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.matrices.ddm.DDM.scc" title="Permalink to this definition">¶</a></dt>
<dd><p>Strongly connected components of a square matrix <em>a</em>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.matrices.sdm</span> <span class="kn">import</span> <span class="n">DDM</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">A</span> <span class="o">=</span> <span class="n">DDM</span><span class="p">([[</span><span class="n">ZZ</span><span class="p">(</span><span class="mi">1</span><span class="p">),</span> <span class="n">ZZ</span><span class="p">(</span><span class="mi">0</span><span class="p">)],</span> <span class="p">[</span><span class="n">ZZ</span><span class="p">(</span><span class="mi">0</span><span class="p">),</span> <span class="n">ZZ</span><span class="p">(</span><span class="mi">1</span><span class="p">)]],</span> <span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">2</span><span class="p">),</span> <span class="n">ZZ</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">A</span><span class="o">.</span><span class="n">scc</span><span class="p">()</span>
<span class="go">[[0], [1]]</span>
</pre></div>
</div>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<p><a class="reference internal" href="#sympy.polys.matrices.domainmatrix.DomainMatrix.scc" title="sympy.polys.matrices.domainmatrix.DomainMatrix.scc"><code class="xref py py-obj docutils literal notranslate"><span class="pre">sympy.polys.matrices.domainmatrix.DomainMatrix.scc</span></code></a></p>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.matrices.ddm.DDM.sub">
<span class="sig-name descname"><span class="pre">sub</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">b</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/matrices/ddm.py#L239-L244"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.matrices.ddm.DDM.sub" title="Permalink to this definition">¶</a></dt>
<dd><p>a - b</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.matrices.ddm.DDM.vstack">
<span class="sig-name descname"><span class="pre">vstack</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">B</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/matrices/ddm.py#L311-L342"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.matrices.ddm.DDM.vstack" title="Permalink to this definition">¶</a></dt>
<dd><p>Vertically stacks <a class="reference internal" href="#sympy.polys.matrices.ddm.DDM" title="sympy.polys.matrices.ddm.DDM"><code class="xref py py-class docutils literal notranslate"><span class="pre">DDM</span></code></a> matrices.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.matrices.sdm</span> <span class="kn">import</span> <span class="n">DDM</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">A</span> <span class="o">=</span> <span class="n">DDM</span><span class="p">([[</span><span class="n">ZZ</span><span class="p">(</span><span class="mi">1</span><span class="p">),</span> <span class="n">ZZ</span><span class="p">(</span><span class="mi">2</span><span class="p">)],</span> <span class="p">[</span><span class="n">ZZ</span><span class="p">(</span><span class="mi">3</span><span class="p">),</span> <span class="n">ZZ</span><span class="p">(</span><span class="mi">4</span><span class="p">)]],</span> <span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">2</span><span class="p">),</span> <span class="n">ZZ</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">B</span> <span class="o">=</span> <span class="n">DDM</span><span class="p">([[</span><span class="n">ZZ</span><span class="p">(</span><span class="mi">5</span><span class="p">),</span> <span class="n">ZZ</span><span class="p">(</span><span class="mi">6</span><span class="p">)],</span> <span class="p">[</span><span class="n">ZZ</span><span class="p">(</span><span class="mi">7</span><span class="p">),</span> <span class="n">ZZ</span><span class="p">(</span><span class="mi">8</span><span class="p">)]],</span> <span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">2</span><span class="p">),</span> <span class="n">ZZ</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">A</span><span class="o">.</span><span class="n">vstack</span><span class="p">(</span><span class="n">B</span><span class="p">)</span>
<span class="go">[[1, 2], [3, 4], [5, 6], [7, 8]]</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">C</span> <span class="o">=</span> <span class="n">DDM</span><span class="p">([[</span><span class="n">ZZ</span><span class="p">(</span><span class="mi">9</span><span class="p">),</span> <span class="n">ZZ</span><span class="p">(</span><span class="mi">10</span><span class="p">)],</span> <span class="p">[</span><span class="n">ZZ</span><span class="p">(</span><span class="mi">11</span><span class="p">),</span> <span class="n">ZZ</span><span class="p">(</span><span class="mi">12</span><span class="p">)]],</span> <span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">2</span><span class="p">),</span> <span class="n">ZZ</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">A</span><span class="o">.</span><span class="n">vstack</span><span class="p">(</span><span class="n">B</span><span class="p">,</span> <span class="n">C</span><span class="p">)</span>
<span class="go">[[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12]]</span>
</pre></div>
</div>
</dd></dl>

</dd></dl>

</section>
<section id="sdm-class-reference">
<h2>SDM Class Reference<a class="headerlink" href="#sdm-class-reference" title="Permalink to this headline">¶</a></h2>
<dl class="py class">
<dt class="sig sig-object py" id="sympy.polys.matrices.sdm.SDM">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">sympy.polys.matrices.sdm.</span></span><span class="sig-name descname"><span class="pre">SDM</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">elemsdict</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">shape</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">domain</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/matrices/sdm.py#L17-L832"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.matrices.sdm.SDM" title="Permalink to this definition">¶</a></dt>
<dd><p>Sparse matrix based on polys domain elements</p>
<p>This is a dict subclass and is a wrapper for a dict of dicts that supports
basic matrix arithmetic +, -, <em>, *</em>.</p>
<p>In order to create a new <a class="reference internal" href="#sympy.polys.matrices.sdm.SDM" title="sympy.polys.matrices.sdm.SDM"><code class="xref py py-class docutils literal notranslate"><span class="pre">SDM</span></code></a>, a dict
of dicts mapping non-zero elements to their
corresponding row and column in the matrix is needed.</p>
<p>We also need to specify the shape and <a class="reference internal" href="domainsref.html#sympy.polys.domains.domain.Domain" title="sympy.polys.domains.domain.Domain"><code class="xref py py-class docutils literal notranslate"><span class="pre">Domain</span></code></a>
of our <a class="reference internal" href="#sympy.polys.matrices.sdm.SDM" title="sympy.polys.matrices.sdm.SDM"><code class="xref py py-class docutils literal notranslate"><span class="pre">SDM</span></code></a> object.</p>
<p>We declare a 2x2 <a class="reference internal" href="#sympy.polys.matrices.sdm.SDM" title="sympy.polys.matrices.sdm.SDM"><code class="xref py py-class docutils literal notranslate"><span class="pre">SDM</span></code></a> matrix belonging
to QQ domain as shown below.
The 2x2 Matrix in the example is</p>
<div class="math notranslate nohighlight">
\[\begin{split}A = \left[\begin{array}{ccc}
     0 &amp; \frac{1}{2} \\
     0 &amp; 0 \end{array} \right]\end{split}\]</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.matrices.sdm</span> <span class="kn">import</span> <span class="n">SDM</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">QQ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">elemsdict</span> <span class="o">=</span> <span class="p">{</span><span class="mi">0</span><span class="p">:{</span><span class="mi">1</span><span class="p">:</span><span class="n">QQ</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">)}}</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">A</span> <span class="o">=</span> <span class="n">SDM</span><span class="p">(</span><span class="n">elemsdict</span><span class="p">,</span> <span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">2</span><span class="p">),</span> <span class="n">QQ</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">A</span>
<span class="go">{0: {1: 1/2}}</span>
</pre></div>
</div>
<p>We can manipulate <a class="reference internal" href="#sympy.polys.matrices.sdm.SDM" title="sympy.polys.matrices.sdm.SDM"><code class="xref py py-class docutils literal notranslate"><span class="pre">SDM</span></code></a> the same way
as a Matrix class</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">A</span> <span class="o">=</span> <span class="n">SDM</span><span class="p">({</span><span class="mi">0</span><span class="p">:{</span><span class="mi">1</span><span class="p">:</span> <span class="n">ZZ</span><span class="p">(</span><span class="mi">2</span><span class="p">)},</span> <span class="mi">1</span><span class="p">:{</span><span class="mi">0</span><span class="p">:</span><span class="n">ZZ</span><span class="p">(</span><span class="mi">1</span><span class="p">)}},</span> <span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">2</span><span class="p">),</span> <span class="n">ZZ</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">B</span>  <span class="o">=</span> <span class="n">SDM</span><span class="p">({</span><span class="mi">0</span><span class="p">:{</span><span class="mi">0</span><span class="p">:</span> <span class="n">ZZ</span><span class="p">(</span><span class="mi">3</span><span class="p">)},</span> <span class="mi">1</span><span class="p">:{</span><span class="mi">1</span><span class="p">:</span><span class="n">ZZ</span><span class="p">(</span><span class="mi">4</span><span class="p">)}},</span> <span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">2</span><span class="p">),</span> <span class="n">ZZ</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">A</span> <span class="o">+</span> <span class="n">B</span>
<span class="go">{0: {0: 3, 1: 2}, 1: {0: 1, 1: 4}}</span>
</pre></div>
</div>
<p>Multiplication</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">A</span><span class="o">*</span><span class="n">B</span>
<span class="go">{0: {1: 8}, 1: {0: 3}}</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">A</span><span class="o">*</span><span class="n">ZZ</span><span class="p">(</span><span class="mi">2</span><span class="p">)</span>
<span class="go">{0: {1: 4}, 1: {0: 2}}</span>
</pre></div>
</div>
<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.matrices.sdm.SDM.add">
<span class="sig-name descname"><span class="pre">add</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">B</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/matrices/sdm.py#L515-L533"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.matrices.sdm.SDM.add" title="Permalink to this definition">¶</a></dt>
<dd><p>Adds two <a class="reference internal" href="#sympy.polys.matrices.sdm.SDM" title="sympy.polys.matrices.sdm.SDM"><code class="xref py py-class docutils literal notranslate"><span class="pre">SDM</span></code></a> matrices</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.matrices.sdm</span> <span class="kn">import</span> <span class="n">SDM</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">A</span> <span class="o">=</span> <span class="n">SDM</span><span class="p">({</span><span class="mi">0</span><span class="p">:{</span><span class="mi">1</span><span class="p">:</span> <span class="n">ZZ</span><span class="p">(</span><span class="mi">2</span><span class="p">)},</span> <span class="mi">1</span><span class="p">:{</span><span class="mi">0</span><span class="p">:</span><span class="n">ZZ</span><span class="p">(</span><span class="mi">1</span><span class="p">)}},</span> <span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">2</span><span class="p">),</span> <span class="n">ZZ</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">B</span> <span class="o">=</span> <span class="n">SDM</span><span class="p">({</span><span class="mi">0</span><span class="p">:{</span><span class="mi">0</span><span class="p">:</span> <span class="n">ZZ</span><span class="p">(</span><span class="mi">3</span><span class="p">)},</span> <span class="mi">1</span><span class="p">:{</span><span class="mi">1</span><span class="p">:</span><span class="n">ZZ</span><span class="p">(</span><span class="mi">4</span><span class="p">)}},</span> <span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">2</span><span class="p">),</span> <span class="n">ZZ</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">A</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="n">B</span><span class="p">)</span>
<span class="go">{0: {0: 3, 1: 2}, 1: {0: 1, 1: 4}}</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.matrices.sdm.SDM.charpoly">
<span class="sig-name descname"><span class="pre">charpoly</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/matrices/sdm.py#L807-L832"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.matrices.sdm.SDM.charpoly" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns the coefficients of the characteristic polynomial
of the <a class="reference internal" href="#sympy.polys.matrices.sdm.SDM" title="sympy.polys.matrices.sdm.SDM"><code class="xref py py-class docutils literal notranslate"><span class="pre">SDM</span></code></a> matrix. These elements will be domain elements.
The domain of the elements will be same as domain of the <a class="reference internal" href="#sympy.polys.matrices.sdm.SDM" title="sympy.polys.matrices.sdm.SDM"><code class="xref py py-class docutils literal notranslate"><span class="pre">SDM</span></code></a>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">QQ</span><span class="p">,</span> <span class="n">Symbol</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.matrices.sdm</span> <span class="kn">import</span> <span class="n">SDM</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys</span> <span class="kn">import</span> <span class="n">Poly</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">A</span> <span class="o">=</span> <span class="n">SDM</span><span class="p">({</span><span class="mi">0</span><span class="p">:{</span><span class="mi">0</span><span class="p">:</span><span class="n">QQ</span><span class="p">(</span><span class="mi">1</span><span class="p">),</span> <span class="mi">1</span><span class="p">:</span><span class="n">QQ</span><span class="p">(</span><span class="mi">2</span><span class="p">)},</span> <span class="mi">1</span><span class="p">:{</span><span class="mi">0</span><span class="p">:</span><span class="n">QQ</span><span class="p">(</span><span class="mi">3</span><span class="p">),</span> <span class="mi">1</span><span class="p">:</span><span class="n">QQ</span><span class="p">(</span><span class="mi">4</span><span class="p">)}},</span> <span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">2</span><span class="p">),</span> <span class="n">QQ</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">A</span><span class="o">.</span><span class="n">charpoly</span><span class="p">()</span>
<span class="go">[1, -5, -2]</span>
</pre></div>
</div>
<p>We can create a polynomial using the
coefficients using <a class="reference internal" href="reference.html#sympy.polys.polytools.Poly" title="sympy.polys.polytools.Poly"><code class="xref py py-class docutils literal notranslate"><span class="pre">Poly</span></code></a></p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">x</span> <span class="o">=</span> <span class="n">Symbol</span><span class="p">(</span><span class="s1">&#39;x&#39;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">p</span> <span class="o">=</span> <span class="n">Poly</span><span class="p">(</span><span class="n">A</span><span class="o">.</span><span class="n">charpoly</span><span class="p">(),</span> <span class="n">x</span><span class="p">,</span> <span class="n">domain</span><span class="o">=</span><span class="n">A</span><span class="o">.</span><span class="n">domain</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">p</span>
<span class="go">Poly(x**2 - 5*x - 2, x, domain=&#39;QQ&#39;)</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.matrices.sdm.SDM.convert_to">
<span class="sig-name descname"><span class="pre">convert_to</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">K</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/matrices/sdm.py#L572-L591"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.matrices.sdm.SDM.convert_to" title="Permalink to this definition">¶</a></dt>
<dd><p>Converts the <a class="reference internal" href="domainsref.html#sympy.polys.domains.domain.Domain" title="sympy.polys.domains.domain.Domain"><code class="xref py py-class docutils literal notranslate"><span class="pre">Domain</span></code></a> of a <a class="reference internal" href="#sympy.polys.matrices.sdm.SDM" title="sympy.polys.matrices.sdm.SDM"><code class="xref py py-class docutils literal notranslate"><span class="pre">SDM</span></code></a> matrix to K</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">ZZ</span><span class="p">,</span> <span class="n">QQ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.matrices.sdm</span> <span class="kn">import</span> <span class="n">SDM</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">A</span> <span class="o">=</span> <span class="n">SDM</span><span class="p">({</span><span class="mi">0</span><span class="p">:{</span><span class="mi">1</span><span class="p">:</span> <span class="n">ZZ</span><span class="p">(</span><span class="mi">2</span><span class="p">)},</span> <span class="mi">1</span><span class="p">:{</span><span class="mi">0</span><span class="p">:</span><span class="n">ZZ</span><span class="p">(</span><span class="mi">1</span><span class="p">)}},</span> <span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">2</span><span class="p">),</span> <span class="n">ZZ</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">A</span><span class="o">.</span><span class="n">convert_to</span><span class="p">(</span><span class="n">QQ</span><span class="p">)</span>
<span class="go">{0: {1: 2}, 1: {0: 1}}</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.matrices.sdm.SDM.copy">
<span class="sig-name descname"><span class="pre">copy</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/matrices/sdm.py#L205-L222"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.matrices.sdm.SDM.copy" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns the copy of a <a class="reference internal" href="#sympy.polys.matrices.sdm.SDM" title="sympy.polys.matrices.sdm.SDM"><code class="xref py py-class docutils literal notranslate"><span class="pre">SDM</span></code></a> object</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.matrices.sdm</span> <span class="kn">import</span> <span class="n">SDM</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">QQ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">elemsdict</span> <span class="o">=</span> <span class="p">{</span><span class="mi">0</span><span class="p">:{</span><span class="mi">1</span><span class="p">:</span><span class="n">QQ</span><span class="p">(</span><span class="mi">2</span><span class="p">)},</span> <span class="mi">1</span><span class="p">:{}}</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">A</span> <span class="o">=</span> <span class="n">SDM</span><span class="p">(</span><span class="n">elemsdict</span><span class="p">,</span> <span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">2</span><span class="p">),</span> <span class="n">QQ</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">B</span> <span class="o">=</span> <span class="n">A</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">B</span>
<span class="go">{0: {1: 2}, 1: {}}</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.matrices.sdm.SDM.det">
<span class="sig-name descname"><span class="pre">det</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/matrices/sdm.py#L651-L665"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.matrices.sdm.SDM.det" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns determinant of A</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">QQ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.matrices.sdm</span> <span class="kn">import</span> <span class="n">SDM</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">A</span> <span class="o">=</span> <span class="n">SDM</span><span class="p">({</span><span class="mi">0</span><span class="p">:{</span><span class="mi">0</span><span class="p">:</span><span class="n">QQ</span><span class="p">(</span><span class="mi">1</span><span class="p">),</span> <span class="mi">1</span><span class="p">:</span><span class="n">QQ</span><span class="p">(</span><span class="mi">2</span><span class="p">)},</span> <span class="mi">1</span><span class="p">:{</span><span class="mi">0</span><span class="p">:</span><span class="n">QQ</span><span class="p">(</span><span class="mi">3</span><span class="p">),</span> <span class="mi">1</span><span class="p">:</span><span class="n">QQ</span><span class="p">(</span><span class="mi">4</span><span class="p">)}},</span> <span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">2</span><span class="p">),</span> <span class="n">QQ</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">A</span><span class="o">.</span><span class="n">det</span><span class="p">()</span>
<span class="go">-2</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.matrices.sdm.SDM.eye">
<em class="property"><span class="pre">classmethod</span> </em><span class="sig-name descname"><span class="pre">eye</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">shape</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">domain</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/matrices/sdm.py#L369-L389"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.matrices.sdm.SDM.eye" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns a identity <a class="reference internal" href="#sympy.polys.matrices.sdm.SDM" title="sympy.polys.matrices.sdm.SDM"><code class="xref py py-class docutils literal notranslate"><span class="pre">SDM</span></code></a> matrix of dimensions
size x size, belonging to the specified domain</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.matrices.sdm</span> <span class="kn">import</span> <span class="n">SDM</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">QQ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">I</span> <span class="o">=</span> <span class="n">SDM</span><span class="o">.</span><span class="n">eye</span><span class="p">((</span><span class="mi">2</span><span class="p">,</span> <span class="mi">2</span><span class="p">),</span> <span class="n">QQ</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">I</span>
<span class="go">{0: {0: 1}, 1: {1: 1}}</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.matrices.sdm.SDM.from_ddm">
<em class="property"><span class="pre">classmethod</span> </em><span class="sig-name descname"><span class="pre">from_ddm</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">ddm</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/matrices/sdm.py#L263-L281"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.matrices.sdm.SDM.from_ddm" title="Permalink to this definition">¶</a></dt>
<dd><p>converts object of <a class="reference internal" href="#sympy.polys.matrices.ddm.DDM" title="sympy.polys.matrices.ddm.DDM"><code class="xref py py-class docutils literal notranslate"><span class="pre">DDM</span></code></a> to
<a class="reference internal" href="#sympy.polys.matrices.sdm.SDM" title="sympy.polys.matrices.sdm.SDM"><code class="xref py py-class docutils literal notranslate"><span class="pre">SDM</span></code></a></p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.matrices.ddm</span> <span class="kn">import</span> <span class="n">DDM</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.matrices.sdm</span> <span class="kn">import</span> <span class="n">SDM</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">QQ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">ddm</span> <span class="o">=</span> <span class="n">DDM</span><span class="p">(</span> <span class="p">[[</span><span class="n">QQ</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">),</span> <span class="mi">0</span><span class="p">],</span> <span class="p">[</span><span class="mi">0</span><span class="p">,</span> <span class="n">QQ</span><span class="p">(</span><span class="mi">3</span><span class="p">,</span> <span class="mi">4</span><span class="p">)]],</span> <span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">2</span><span class="p">),</span> <span class="n">QQ</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">A</span> <span class="o">=</span> <span class="n">SDM</span><span class="o">.</span><span class="n">from_ddm</span><span class="p">(</span><span class="n">ddm</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">A</span>
<span class="go">{0: {0: 1/2}, 1: {1: 3/4}}</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.matrices.sdm.SDM.from_list">
<em class="property"><span class="pre">classmethod</span> </em><span class="sig-name descname"><span class="pre">from_list</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">ddm</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">shape</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">domain</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/matrices/sdm.py#L224-L261"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.matrices.sdm.SDM.from_list" title="Permalink to this definition">¶</a></dt>
<dd><dl class="field-list">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>ddm:</strong></p>
<blockquote>
<div><p>list of lists containing domain elements</p>
</div></blockquote>
<p><strong>shape:</strong></p>
<blockquote>
<div><p>Dimensions of <a class="reference internal" href="#sympy.polys.matrices.sdm.SDM" title="sympy.polys.matrices.sdm.SDM"><code class="xref py py-class docutils literal notranslate"><span class="pre">SDM</span></code></a> matrix</p>
</div></blockquote>
<p><strong>domain:</strong></p>
<blockquote>
<div><p>Represents <a class="reference internal" href="domainsref.html#sympy.polys.domains.domain.Domain" title="sympy.polys.domains.domain.Domain"><code class="xref py py-class docutils literal notranslate"><span class="pre">Domain</span></code></a> of <a class="reference internal" href="#sympy.polys.matrices.sdm.SDM" title="sympy.polys.matrices.sdm.SDM"><code class="xref py py-class docutils literal notranslate"><span class="pre">SDM</span></code></a> object</p>
</div></blockquote>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p><a class="reference internal" href="#sympy.polys.matrices.sdm.SDM" title="sympy.polys.matrices.sdm.SDM"><code class="xref py py-class docutils literal notranslate"><span class="pre">SDM</span></code></a> containing elements of ddm</p>
</dd>
</dl>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.matrices.sdm</span> <span class="kn">import</span> <span class="n">SDM</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">QQ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">ddm</span> <span class="o">=</span> <span class="p">[[</span><span class="n">QQ</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">),</span> <span class="n">QQ</span><span class="p">(</span><span class="mi">0</span><span class="p">)],</span> <span class="p">[</span><span class="n">QQ</span><span class="p">(</span><span class="mi">0</span><span class="p">),</span> <span class="n">QQ</span><span class="p">(</span><span class="mi">3</span><span class="p">,</span> <span class="mi">4</span><span class="p">)]]</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">A</span> <span class="o">=</span> <span class="n">SDM</span><span class="o">.</span><span class="n">from_list</span><span class="p">(</span><span class="n">ddm</span><span class="p">,</span> <span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">2</span><span class="p">),</span> <span class="n">QQ</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">A</span>
<span class="go">{0: {0: 1/2}, 1: {1: 3/4}}</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.matrices.sdm.SDM.hstack">
<span class="sig-name descname"><span class="pre">hstack</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">B</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/matrices/sdm.py#L733-L768"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.matrices.sdm.SDM.hstack" title="Permalink to this definition">¶</a></dt>
<dd><p>Horizontally stacks <a class="reference internal" href="#sympy.polys.matrices.sdm.SDM" title="sympy.polys.matrices.sdm.SDM"><code class="xref py py-class docutils literal notranslate"><span class="pre">SDM</span></code></a> matrices.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.matrices.sdm</span> <span class="kn">import</span> <span class="n">SDM</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">A</span> <span class="o">=</span> <span class="n">SDM</span><span class="p">({</span><span class="mi">0</span><span class="p">:</span> <span class="p">{</span><span class="mi">0</span><span class="p">:</span> <span class="n">ZZ</span><span class="p">(</span><span class="mi">1</span><span class="p">),</span> <span class="mi">1</span><span class="p">:</span> <span class="n">ZZ</span><span class="p">(</span><span class="mi">2</span><span class="p">)},</span> <span class="mi">1</span><span class="p">:</span> <span class="p">{</span><span class="mi">0</span><span class="p">:</span> <span class="n">ZZ</span><span class="p">(</span><span class="mi">3</span><span class="p">),</span> <span class="mi">1</span><span class="p">:</span> <span class="n">ZZ</span><span class="p">(</span><span class="mi">4</span><span class="p">)}},</span> <span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">2</span><span class="p">),</span> <span class="n">ZZ</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">B</span> <span class="o">=</span> <span class="n">SDM</span><span class="p">({</span><span class="mi">0</span><span class="p">:</span> <span class="p">{</span><span class="mi">0</span><span class="p">:</span> <span class="n">ZZ</span><span class="p">(</span><span class="mi">5</span><span class="p">),</span> <span class="mi">1</span><span class="p">:</span> <span class="n">ZZ</span><span class="p">(</span><span class="mi">6</span><span class="p">)},</span> <span class="mi">1</span><span class="p">:</span> <span class="p">{</span><span class="mi">0</span><span class="p">:</span> <span class="n">ZZ</span><span class="p">(</span><span class="mi">7</span><span class="p">),</span> <span class="mi">1</span><span class="p">:</span> <span class="n">ZZ</span><span class="p">(</span><span class="mi">8</span><span class="p">)}},</span> <span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">2</span><span class="p">),</span> <span class="n">ZZ</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">A</span><span class="o">.</span><span class="n">hstack</span><span class="p">(</span><span class="n">B</span><span class="p">)</span>
<span class="go">{0: {0: 1, 1: 2, 2: 5, 3: 6}, 1: {0: 3, 1: 4, 2: 7, 3: 8}}</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">C</span> <span class="o">=</span> <span class="n">SDM</span><span class="p">({</span><span class="mi">0</span><span class="p">:</span> <span class="p">{</span><span class="mi">0</span><span class="p">:</span> <span class="n">ZZ</span><span class="p">(</span><span class="mi">9</span><span class="p">),</span> <span class="mi">1</span><span class="p">:</span> <span class="n">ZZ</span><span class="p">(</span><span class="mi">10</span><span class="p">)},</span> <span class="mi">1</span><span class="p">:</span> <span class="p">{</span><span class="mi">0</span><span class="p">:</span> <span class="n">ZZ</span><span class="p">(</span><span class="mi">11</span><span class="p">),</span> <span class="mi">1</span><span class="p">:</span> <span class="n">ZZ</span><span class="p">(</span><span class="mi">12</span><span class="p">)}},</span> <span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">2</span><span class="p">),</span> <span class="n">ZZ</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">A</span><span class="o">.</span><span class="n">hstack</span><span class="p">(</span><span class="n">B</span><span class="p">,</span> <span class="n">C</span><span class="p">)</span>
<span class="go">{0: {0: 1, 1: 2, 2: 5, 3: 6, 4: 9, 5: 10}, 1: {0: 3, 1: 4, 2: 7, 3: 8, 4: 11, 5: 12}}</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.matrices.sdm.SDM.inv">
<span class="sig-name descname"><span class="pre">inv</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/matrices/sdm.py#L634-L649"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.matrices.sdm.SDM.inv" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns inverse of a matrix A</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">QQ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.matrices.sdm</span> <span class="kn">import</span> <span class="n">SDM</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">A</span> <span class="o">=</span> <span class="n">SDM</span><span class="p">({</span><span class="mi">0</span><span class="p">:{</span><span class="mi">0</span><span class="p">:</span><span class="n">QQ</span><span class="p">(</span><span class="mi">1</span><span class="p">),</span> <span class="mi">1</span><span class="p">:</span><span class="n">QQ</span><span class="p">(</span><span class="mi">2</span><span class="p">)},</span> <span class="mi">1</span><span class="p">:{</span><span class="mi">0</span><span class="p">:</span><span class="n">QQ</span><span class="p">(</span><span class="mi">3</span><span class="p">),</span> <span class="mi">1</span><span class="p">:</span><span class="n">QQ</span><span class="p">(</span><span class="mi">4</span><span class="p">)}},</span> <span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">2</span><span class="p">),</span> <span class="n">QQ</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">A</span><span class="o">.</span><span class="n">inv</span><span class="p">()</span>
<span class="go">{0: {0: -2, 1: 1}, 1: {0: 3/2, 1: -1/2}}</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.matrices.sdm.SDM.lu">
<span class="sig-name descname"><span class="pre">lu</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/matrices/sdm.py#L667-L683"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.matrices.sdm.SDM.lu" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns LU decomposition for a matrix A</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">QQ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.matrices.sdm</span> <span class="kn">import</span> <span class="n">SDM</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">A</span> <span class="o">=</span> <span class="n">SDM</span><span class="p">({</span><span class="mi">0</span><span class="p">:{</span><span class="mi">0</span><span class="p">:</span><span class="n">QQ</span><span class="p">(</span><span class="mi">1</span><span class="p">),</span> <span class="mi">1</span><span class="p">:</span><span class="n">QQ</span><span class="p">(</span><span class="mi">2</span><span class="p">)},</span> <span class="mi">1</span><span class="p">:{</span><span class="mi">0</span><span class="p">:</span><span class="n">QQ</span><span class="p">(</span><span class="mi">3</span><span class="p">),</span> <span class="mi">1</span><span class="p">:</span><span class="n">QQ</span><span class="p">(</span><span class="mi">4</span><span class="p">)}},</span> <span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">2</span><span class="p">),</span> <span class="n">QQ</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">A</span><span class="o">.</span><span class="n">lu</span><span class="p">()</span>
<span class="go">({0: {0: 1}, 1: {0: 3, 1: 1}}, {0: {0: 1, 1: 2}, 1: {1: -2}}, [])</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.matrices.sdm.SDM.lu_solve">
<span class="sig-name descname"><span class="pre">lu_solve</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">b</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/matrices/sdm.py#L685-L701"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.matrices.sdm.SDM.lu_solve" title="Permalink to this definition">¶</a></dt>
<dd><p>Uses LU decomposition to solve Ax = b,</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">QQ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.matrices.sdm</span> <span class="kn">import</span> <span class="n">SDM</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">A</span> <span class="o">=</span> <span class="n">SDM</span><span class="p">({</span><span class="mi">0</span><span class="p">:{</span><span class="mi">0</span><span class="p">:</span><span class="n">QQ</span><span class="p">(</span><span class="mi">1</span><span class="p">),</span> <span class="mi">1</span><span class="p">:</span><span class="n">QQ</span><span class="p">(</span><span class="mi">2</span><span class="p">)},</span> <span class="mi">1</span><span class="p">:{</span><span class="mi">0</span><span class="p">:</span><span class="n">QQ</span><span class="p">(</span><span class="mi">3</span><span class="p">),</span> <span class="mi">1</span><span class="p">:</span><span class="n">QQ</span><span class="p">(</span><span class="mi">4</span><span class="p">)}},</span> <span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">2</span><span class="p">),</span> <span class="n">QQ</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">b</span> <span class="o">=</span> <span class="n">SDM</span><span class="p">({</span><span class="mi">0</span><span class="p">:{</span><span class="mi">0</span><span class="p">:</span><span class="n">QQ</span><span class="p">(</span><span class="mi">1</span><span class="p">)},</span> <span class="mi">1</span><span class="p">:{</span><span class="mi">0</span><span class="p">:</span><span class="n">QQ</span><span class="p">(</span><span class="mi">2</span><span class="p">)}},</span> <span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">1</span><span class="p">),</span> <span class="n">QQ</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">A</span><span class="o">.</span><span class="n">lu_solve</span><span class="p">(</span><span class="n">b</span><span class="p">)</span>
<span class="go">{1: {0: 1/2}}</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.matrices.sdm.SDM.matmul">
<span class="sig-name descname"><span class="pre">matmul</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">B</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/matrices/sdm.py#L442-L482"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.matrices.sdm.SDM.matmul" title="Permalink to this definition">¶</a></dt>
<dd><p>Performs matrix multiplication of two SDM matrices</p>
<dl class="field-list">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>A, B: SDM to multiply</strong></p>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>SDM</p>
<blockquote>
<div><p>SDM after multiplication</p>
</div></blockquote>
</dd>
<dt class="field-odd">Raises</dt>
<dd class="field-odd"><p><strong>DomainError</strong></p>
<blockquote>
<div><p>If domain of A does not match
with that of B</p>
</div></blockquote>
</dd>
</dl>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.matrices.sdm</span> <span class="kn">import</span> <span class="n">SDM</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">A</span> <span class="o">=</span> <span class="n">SDM</span><span class="p">({</span><span class="mi">0</span><span class="p">:{</span><span class="mi">1</span><span class="p">:</span> <span class="n">ZZ</span><span class="p">(</span><span class="mi">2</span><span class="p">)},</span> <span class="mi">1</span><span class="p">:{</span><span class="mi">0</span><span class="p">:</span><span class="n">ZZ</span><span class="p">(</span><span class="mi">1</span><span class="p">)}},</span> <span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">2</span><span class="p">),</span> <span class="n">ZZ</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">B</span> <span class="o">=</span> <span class="n">SDM</span><span class="p">({</span><span class="mi">0</span><span class="p">:{</span><span class="mi">0</span><span class="p">:</span><span class="n">ZZ</span><span class="p">(</span><span class="mi">2</span><span class="p">),</span> <span class="mi">1</span><span class="p">:</span><span class="n">ZZ</span><span class="p">(</span><span class="mi">3</span><span class="p">)},</span> <span class="mi">1</span><span class="p">:{</span><span class="mi">0</span><span class="p">:</span><span class="n">ZZ</span><span class="p">(</span><span class="mi">4</span><span class="p">)}},</span> <span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">2</span><span class="p">),</span> <span class="n">ZZ</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">A</span><span class="o">.</span><span class="n">matmul</span><span class="p">(</span><span class="n">B</span><span class="p">)</span>
<span class="go">{0: {0: 8}, 1: {0: 2, 1: 3}}</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.matrices.sdm.SDM.mul">
<span class="sig-name descname"><span class="pre">mul</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">b</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/matrices/sdm.py#L484-L499"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.matrices.sdm.SDM.mul" title="Permalink to this definition">¶</a></dt>
<dd><p>Multiplies each element of A with a scalar b</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.matrices.sdm</span> <span class="kn">import</span> <span class="n">SDM</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">A</span> <span class="o">=</span> <span class="n">SDM</span><span class="p">({</span><span class="mi">0</span><span class="p">:{</span><span class="mi">1</span><span class="p">:</span> <span class="n">ZZ</span><span class="p">(</span><span class="mi">2</span><span class="p">)},</span> <span class="mi">1</span><span class="p">:{</span><span class="mi">0</span><span class="p">:</span><span class="n">ZZ</span><span class="p">(</span><span class="mi">1</span><span class="p">)}},</span> <span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">2</span><span class="p">),</span> <span class="n">ZZ</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">A</span><span class="o">.</span><span class="n">mul</span><span class="p">(</span><span class="n">ZZ</span><span class="p">(</span><span class="mi">3</span><span class="p">))</span>
<span class="go">{0: {1: 6}, 1: {0: 3}}</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.matrices.sdm.SDM.neg">
<span class="sig-name descname"><span class="pre">neg</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/matrices/sdm.py#L554-L570"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.matrices.sdm.SDM.neg" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns the negative of a <a class="reference internal" href="#sympy.polys.matrices.sdm.SDM" title="sympy.polys.matrices.sdm.SDM"><code class="xref py py-class docutils literal notranslate"><span class="pre">SDM</span></code></a> matrix</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.matrices.sdm</span> <span class="kn">import</span> <span class="n">SDM</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">A</span> <span class="o">=</span> <span class="n">SDM</span><span class="p">({</span><span class="mi">0</span><span class="p">:{</span><span class="mi">1</span><span class="p">:</span> <span class="n">ZZ</span><span class="p">(</span><span class="mi">2</span><span class="p">)},</span> <span class="mi">1</span><span class="p">:{</span><span class="mi">0</span><span class="p">:</span><span class="n">ZZ</span><span class="p">(</span><span class="mi">1</span><span class="p">)}},</span> <span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">2</span><span class="p">),</span> <span class="n">ZZ</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">A</span><span class="o">.</span><span class="n">neg</span><span class="p">()</span>
<span class="go">{0: {1: -2}, 1: {0: -1}}</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.matrices.sdm.SDM.new">
<em class="property"><span class="pre">classmethod</span> </em><span class="sig-name descname"><span class="pre">new</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">sdm</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">shape</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">domain</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/matrices/sdm.py#L176-L203"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.matrices.sdm.SDM.new" title="Permalink to this definition">¶</a></dt>
<dd><dl class="field-list">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>sdm: A dict of dicts for non-zero elements in SDM</strong></p>
<p><strong>shape: tuple representing dimension of SDM</strong></p>
<p><strong>domain: Represents :py:class:`~.Domain` of SDM</strong></p>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>An <a class="reference internal" href="#sympy.polys.matrices.sdm.SDM" title="sympy.polys.matrices.sdm.SDM"><code class="xref py py-class docutils literal notranslate"><span class="pre">SDM</span></code></a> object</p>
</dd>
</dl>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.matrices.sdm</span> <span class="kn">import</span> <span class="n">SDM</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">QQ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">elemsdict</span> <span class="o">=</span> <span class="p">{</span><span class="mi">0</span><span class="p">:{</span><span class="mi">1</span><span class="p">:</span> <span class="n">QQ</span><span class="p">(</span><span class="mi">2</span><span class="p">)}}</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">A</span> <span class="o">=</span> <span class="n">SDM</span><span class="o">.</span><span class="n">new</span><span class="p">(</span><span class="n">elemsdict</span><span class="p">,</span> <span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">2</span><span class="p">),</span> <span class="n">QQ</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">A</span>
<span class="go">{0: {1: 2}}</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.matrices.sdm.SDM.nullspace">
<span class="sig-name descname"><span class="pre">nullspace</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/matrices/sdm.py#L703-L724"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.matrices.sdm.SDM.nullspace" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns nullspace for a <a class="reference internal" href="#sympy.polys.matrices.sdm.SDM" title="sympy.polys.matrices.sdm.SDM"><code class="xref py py-class docutils literal notranslate"><span class="pre">SDM</span></code></a> matrix A</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">QQ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.matrices.sdm</span> <span class="kn">import</span> <span class="n">SDM</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">A</span> <span class="o">=</span> <span class="n">SDM</span><span class="p">({</span><span class="mi">0</span><span class="p">:{</span><span class="mi">0</span><span class="p">:</span><span class="n">QQ</span><span class="p">(</span><span class="mi">1</span><span class="p">),</span> <span class="mi">1</span><span class="p">:</span><span class="n">QQ</span><span class="p">(</span><span class="mi">2</span><span class="p">)},</span> <span class="mi">1</span><span class="p">:{</span><span class="mi">0</span><span class="p">:</span> <span class="n">QQ</span><span class="p">(</span><span class="mi">2</span><span class="p">),</span> <span class="mi">1</span><span class="p">:</span> <span class="n">QQ</span><span class="p">(</span><span class="mi">4</span><span class="p">)}},</span> <span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">2</span><span class="p">),</span> <span class="n">QQ</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">A</span><span class="o">.</span><span class="n">nullspace</span><span class="p">()</span>
<span class="go">({0: {0: -2, 1: 1}}, [1])</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.matrices.sdm.SDM.rref">
<span class="sig-name descname"><span class="pre">rref</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/matrices/sdm.py#L616-L632"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.matrices.sdm.SDM.rref" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns reduced-row echelon form and list of pivots for the <a class="reference internal" href="#sympy.polys.matrices.sdm.SDM" title="sympy.polys.matrices.sdm.SDM"><code class="xref py py-class docutils literal notranslate"><span class="pre">SDM</span></code></a></p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">QQ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.matrices.sdm</span> <span class="kn">import</span> <span class="n">SDM</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">A</span> <span class="o">=</span> <span class="n">SDM</span><span class="p">({</span><span class="mi">0</span><span class="p">:{</span><span class="mi">0</span><span class="p">:</span><span class="n">QQ</span><span class="p">(</span><span class="mi">1</span><span class="p">),</span> <span class="mi">1</span><span class="p">:</span><span class="n">QQ</span><span class="p">(</span><span class="mi">2</span><span class="p">)},</span> <span class="mi">1</span><span class="p">:{</span><span class="mi">0</span><span class="p">:</span><span class="n">QQ</span><span class="p">(</span><span class="mi">2</span><span class="p">),</span> <span class="mi">1</span><span class="p">:</span><span class="n">QQ</span><span class="p">(</span><span class="mi">4</span><span class="p">)}},</span> <span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">2</span><span class="p">),</span> <span class="n">QQ</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">A</span><span class="o">.</span><span class="n">rref</span><span class="p">()</span>
<span class="go">({0: {0: 1, 1: 2}}, [0])</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.matrices.sdm.SDM.scc">
<span class="sig-name descname"><span class="pre">scc</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/matrices/sdm.py#L593-L614"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.matrices.sdm.SDM.scc" title="Permalink to this definition">¶</a></dt>
<dd><p>Strongly connected components of a square matrix <em>A</em>.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.matrices.sdm</span> <span class="kn">import</span> <span class="n">SDM</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">A</span> <span class="o">=</span> <span class="n">SDM</span><span class="p">({</span><span class="mi">0</span><span class="p">:{</span><span class="mi">0</span><span class="p">:</span> <span class="n">ZZ</span><span class="p">(</span><span class="mi">2</span><span class="p">)},</span> <span class="mi">1</span><span class="p">:{</span><span class="mi">1</span><span class="p">:</span><span class="n">ZZ</span><span class="p">(</span><span class="mi">1</span><span class="p">)}},</span> <span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">2</span><span class="p">),</span> <span class="n">ZZ</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">A</span><span class="o">.</span><span class="n">scc</span><span class="p">()</span>
<span class="go">[[0], [1]]</span>
</pre></div>
</div>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<p><a class="reference internal" href="#sympy.polys.matrices.domainmatrix.DomainMatrix.scc" title="sympy.polys.matrices.domainmatrix.DomainMatrix.scc"><code class="xref py py-obj docutils literal notranslate"><span class="pre">sympy.polys.matrices.domainmatrix.DomainMatrix.scc</span></code></a></p>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.matrices.sdm.SDM.sub">
<span class="sig-name descname"><span class="pre">sub</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">B</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/matrices/sdm.py#L535-L552"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.matrices.sdm.SDM.sub" title="Permalink to this definition">¶</a></dt>
<dd><p>Subtracts two <a class="reference internal" href="#sympy.polys.matrices.sdm.SDM" title="sympy.polys.matrices.sdm.SDM"><code class="xref py py-class docutils literal notranslate"><span class="pre">SDM</span></code></a> matrices</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.matrices.sdm</span> <span class="kn">import</span> <span class="n">SDM</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">A</span> <span class="o">=</span> <span class="n">SDM</span><span class="p">({</span><span class="mi">0</span><span class="p">:{</span><span class="mi">1</span><span class="p">:</span> <span class="n">ZZ</span><span class="p">(</span><span class="mi">2</span><span class="p">)},</span> <span class="mi">1</span><span class="p">:{</span><span class="mi">0</span><span class="p">:</span><span class="n">ZZ</span><span class="p">(</span><span class="mi">1</span><span class="p">)}},</span> <span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">2</span><span class="p">),</span> <span class="n">ZZ</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">B</span>  <span class="o">=</span> <span class="n">SDM</span><span class="p">({</span><span class="mi">0</span><span class="p">:{</span><span class="mi">0</span><span class="p">:</span> <span class="n">ZZ</span><span class="p">(</span><span class="mi">3</span><span class="p">)},</span> <span class="mi">1</span><span class="p">:{</span><span class="mi">1</span><span class="p">:</span><span class="n">ZZ</span><span class="p">(</span><span class="mi">4</span><span class="p">)}},</span> <span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">2</span><span class="p">),</span> <span class="n">ZZ</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">A</span><span class="o">.</span><span class="n">sub</span><span class="p">(</span><span class="n">B</span><span class="p">)</span>
<span class="go">{0: {0: -3, 1: 2}, 1: {0: 1, 1: -4}}</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.matrices.sdm.SDM.to_ddm">
<span class="sig-name descname"><span class="pre">to_ddm</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/matrices/sdm.py#L319-L333"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.matrices.sdm.SDM.to_ddm" title="Permalink to this definition">¶</a></dt>
<dd><p>Convert a <a class="reference internal" href="#sympy.polys.matrices.sdm.SDM" title="sympy.polys.matrices.sdm.SDM"><code class="xref py py-class docutils literal notranslate"><span class="pre">SDM</span></code></a> object to a <a class="reference internal" href="#sympy.polys.matrices.ddm.DDM" title="sympy.polys.matrices.ddm.DDM"><code class="xref py py-class docutils literal notranslate"><span class="pre">DDM</span></code></a> object</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.matrices.sdm</span> <span class="kn">import</span> <span class="n">SDM</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">QQ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">A</span> <span class="o">=</span> <span class="n">SDM</span><span class="p">({</span><span class="mi">0</span><span class="p">:{</span><span class="mi">1</span><span class="p">:</span><span class="n">QQ</span><span class="p">(</span><span class="mi">2</span><span class="p">)},</span> <span class="mi">1</span><span class="p">:{}},</span> <span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">2</span><span class="p">),</span> <span class="n">QQ</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">A</span><span class="o">.</span><span class="n">to_ddm</span><span class="p">()</span>
<span class="go">[[0, 2], [0, 0]]</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.matrices.sdm.SDM.to_list">
<span class="sig-name descname"><span class="pre">to_list</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/matrices/sdm.py#L283-L305"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.matrices.sdm.SDM.to_list" title="Permalink to this definition">¶</a></dt>
<dd><p>Converts a <a class="reference internal" href="#sympy.polys.matrices.sdm.SDM" title="sympy.polys.matrices.sdm.SDM"><code class="xref py py-class docutils literal notranslate"><span class="pre">SDM</span></code></a> object to a list</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.matrices.sdm</span> <span class="kn">import</span> <span class="n">SDM</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">QQ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">elemsdict</span> <span class="o">=</span> <span class="p">{</span><span class="mi">0</span><span class="p">:{</span><span class="mi">1</span><span class="p">:</span><span class="n">QQ</span><span class="p">(</span><span class="mi">2</span><span class="p">)},</span> <span class="mi">1</span><span class="p">:{}}</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">A</span> <span class="o">=</span> <span class="n">SDM</span><span class="p">(</span><span class="n">elemsdict</span><span class="p">,</span> <span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">2</span><span class="p">),</span> <span class="n">QQ</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">A</span><span class="o">.</span><span class="n">to_list</span><span class="p">()</span>
<span class="go">[[0, 2], [0, 0]]</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.matrices.sdm.SDM.transpose">
<span class="sig-name descname"><span class="pre">transpose</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/matrices/sdm.py#L396-L412"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.matrices.sdm.SDM.transpose" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns the transpose of a <a class="reference internal" href="#sympy.polys.matrices.sdm.SDM" title="sympy.polys.matrices.sdm.SDM"><code class="xref py py-class docutils literal notranslate"><span class="pre">SDM</span></code></a> matrix</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.matrices.sdm</span> <span class="kn">import</span> <span class="n">SDM</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">QQ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">A</span> <span class="o">=</span> <span class="n">SDM</span><span class="p">({</span><span class="mi">0</span><span class="p">:{</span><span class="mi">1</span><span class="p">:</span><span class="n">QQ</span><span class="p">(</span><span class="mi">2</span><span class="p">)},</span> <span class="mi">1</span><span class="p">:{}},</span> <span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">2</span><span class="p">),</span> <span class="n">QQ</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">A</span><span class="o">.</span><span class="n">transpose</span><span class="p">()</span>
<span class="go">{1: {0: 2}}</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.matrices.sdm.SDM.vstack">
<span class="sig-name descname"><span class="pre">vstack</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">B</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/matrices/sdm.py#L770-L801"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.matrices.sdm.SDM.vstack" title="Permalink to this definition">¶</a></dt>
<dd><p>Vertically stacks <a class="reference internal" href="#sympy.polys.matrices.sdm.SDM" title="sympy.polys.matrices.sdm.SDM"><code class="xref py py-class docutils literal notranslate"><span class="pre">SDM</span></code></a> matrices.</p>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">ZZ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.matrices.sdm</span> <span class="kn">import</span> <span class="n">SDM</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">A</span> <span class="o">=</span> <span class="n">SDM</span><span class="p">({</span><span class="mi">0</span><span class="p">:</span> <span class="p">{</span><span class="mi">0</span><span class="p">:</span> <span class="n">ZZ</span><span class="p">(</span><span class="mi">1</span><span class="p">),</span> <span class="mi">1</span><span class="p">:</span> <span class="n">ZZ</span><span class="p">(</span><span class="mi">2</span><span class="p">)},</span> <span class="mi">1</span><span class="p">:</span> <span class="p">{</span><span class="mi">0</span><span class="p">:</span> <span class="n">ZZ</span><span class="p">(</span><span class="mi">3</span><span class="p">),</span> <span class="mi">1</span><span class="p">:</span> <span class="n">ZZ</span><span class="p">(</span><span class="mi">4</span><span class="p">)}},</span> <span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">2</span><span class="p">),</span> <span class="n">ZZ</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">B</span> <span class="o">=</span> <span class="n">SDM</span><span class="p">({</span><span class="mi">0</span><span class="p">:</span> <span class="p">{</span><span class="mi">0</span><span class="p">:</span> <span class="n">ZZ</span><span class="p">(</span><span class="mi">5</span><span class="p">),</span> <span class="mi">1</span><span class="p">:</span> <span class="n">ZZ</span><span class="p">(</span><span class="mi">6</span><span class="p">)},</span> <span class="mi">1</span><span class="p">:</span> <span class="p">{</span><span class="mi">0</span><span class="p">:</span> <span class="n">ZZ</span><span class="p">(</span><span class="mi">7</span><span class="p">),</span> <span class="mi">1</span><span class="p">:</span> <span class="n">ZZ</span><span class="p">(</span><span class="mi">8</span><span class="p">)}},</span> <span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">2</span><span class="p">),</span> <span class="n">ZZ</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">A</span><span class="o">.</span><span class="n">vstack</span><span class="p">(</span><span class="n">B</span><span class="p">)</span>
<span class="go">{0: {0: 1, 1: 2}, 1: {0: 3, 1: 4}, 2: {0: 5, 1: 6}, 3: {0: 7, 1: 8}}</span>
</pre></div>
</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">C</span> <span class="o">=</span> <span class="n">SDM</span><span class="p">({</span><span class="mi">0</span><span class="p">:</span> <span class="p">{</span><span class="mi">0</span><span class="p">:</span> <span class="n">ZZ</span><span class="p">(</span><span class="mi">9</span><span class="p">),</span> <span class="mi">1</span><span class="p">:</span> <span class="n">ZZ</span><span class="p">(</span><span class="mi">10</span><span class="p">)},</span> <span class="mi">1</span><span class="p">:</span> <span class="p">{</span><span class="mi">0</span><span class="p">:</span> <span class="n">ZZ</span><span class="p">(</span><span class="mi">11</span><span class="p">),</span> <span class="mi">1</span><span class="p">:</span> <span class="n">ZZ</span><span class="p">(</span><span class="mi">12</span><span class="p">)}},</span> <span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">2</span><span class="p">),</span> <span class="n">ZZ</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">A</span><span class="o">.</span><span class="n">vstack</span><span class="p">(</span><span class="n">B</span><span class="p">,</span> <span class="n">C</span><span class="p">)</span>
<span class="go">{0: {0: 1, 1: 2}, 1: {0: 3, 1: 4}, 2: {0: 5, 1: 6}, 3: {0: 7, 1: 8}, 4: {0: 9, 1: 10}, 5: {0: 11, 1: 12}}</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.polys.matrices.sdm.SDM.zeros">
<em class="property"><span class="pre">classmethod</span> </em><span class="sig-name descname"><span class="pre">zeros</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">shape</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">domain</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/polys/matrices/sdm.py#L338-L359"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.polys.matrices.sdm.SDM.zeros" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns a <a class="reference internal" href="#sympy.polys.matrices.sdm.SDM" title="sympy.polys.matrices.sdm.SDM"><code class="xref py py-class docutils literal notranslate"><span class="pre">SDM</span></code></a> of size shape,
belonging to the specified domain</p>
<p>In the example below we declare a matrix A where,</p>
<div class="math notranslate nohighlight">
\[\begin{split}A := \left[\begin{array}{ccc}
0 &amp; 0 &amp; 0 \\
0 &amp; 0 &amp; 0 \end{array} \right]\end{split}\]</div>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.polys.matrices.sdm</span> <span class="kn">import</span> <span class="n">SDM</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">QQ</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">A</span> <span class="o">=</span> <span class="n">SDM</span><span class="o">.</span><span class="n">zeros</span><span class="p">((</span><span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">),</span> <span class="n">QQ</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">A</span>
<span class="go">{}</span>
</pre></div>
</div>
</dd></dl>

</dd></dl>

</section>
</section>


            <div class="clearer"></div>
          </div>
        </div>
      </div>
      <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
        <div class="sphinxsidebarwrapper">
            <p class="logo"><a href="../../index.html">
              <img class="logo" src="../../_static/sympylogo.png" alt="Logo"/>
            </a></p>
  <h3><a href="../../index.html">Table of Contents</a></h3>
  <ul>
<li><a class="reference internal" href="#">Introducing the domainmatrix of the poly module</a><ul>
<li><a class="reference internal" href="#what-is-domainmatrix">What is domainmatrix?</a></li>
<li><a class="reference internal" href="#domainmatrix-class-reference">DomainMatrix Class Reference</a></li>
<li><a class="reference internal" href="#ddm-class-reference">DDM Class Reference</a></li>
<li><a class="reference internal" href="#sdm-class-reference">SDM Class Reference</a></li>
</ul>
</li>
</ul>

  <h4>Previous topic</h4>
  <p class="topless"><a href="solvers.html"
                        title="previous chapter">Poly solvers</a></p>
  <h4>Next topic</h4>
  <p class="topless"><a href="../printing.html"
                        title="next chapter">Printing</a></p>
  <div role="note" aria-label="source link">
    <h3>This Page</h3>
    <ul class="this-page-menu">
      <li><a href="../../_sources/modules/polys/domainmatrix.rst.txt"
            rel="nofollow">Show Source</a></li>
    </ul>
   </div>
<div id="searchbox" style="display: none" role="search">
  <h3 id="searchlabel">Quick search</h3>
    <div class="searchformwrapper">
    <form class="search" action="https://docs.sympy.org/latest/search.html" method="get">
      <input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
      <input type="submit" value="Go" />
    </form>
    </div>
</div>
<script>$('#searchbox').show(0);</script>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../../genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="../../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="../printing.html" title="Printing"
             >next</a> |</li>
        <li class="right" >
          <a href="solvers.html" title="Poly solvers"
             >previous</a> |</li>
        <li class="nav-item nav-item-0"><a href="../../index.html">SymPy 1.9 documentation</a> &#187;</li>
          <li class="nav-item nav-item-1"><a href="../index.html" >SymPy Modules Reference</a> &#187;</li>
          <li class="nav-item nav-item-2"><a href="index.html" >Polynomial Manipulation</a> &#187;</li>
        <li class="nav-item nav-item-this"><a href="#">Introducing the domainmatrix of the poly module</a></li> 
      </ul>
    </div>
    <div class="footer" role="contentinfo">
        &#169; Copyright 2021 SymPy Development Team.
      Last updated on Sep 30, 2021.
      Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 4.1.2.
    </div>
  </body>

<!-- Mirrored from docs.sympy.org/latest/modules/polys/domainmatrix.html by HTTrack Website Copier/3.x [XR&CO'2014], Sat, 15 Jan 2022 03:29:07 GMT -->
</html>